Ghost/test/unit/server/data/db/backup.test.js
Hannah Wolfe 9e96b04542
Moved server unit tests into the server folder
- this is a small part of a bit of cleanup of our test files
- the goal is to make the existing tests clearer with a view to making it easier to write more tests
- this makes the test structure follow the codebase structure more closely
- eventually we will colocate the tests as we break the codebase down further
2021-10-06 12:01:09 +01:00

38 lines
1.1 KiB
JavaScript

const should = require('should');
const sinon = require('sinon');
const _ = require('lodash');
const fs = require('fs-extra');
const models = require('../../../../../core/server/models');
const exporter = require('../../../../../core/server/data/exporter');
const dbBackup = require('../../../../../core/server/data/db/backup');
describe('Backup', function () {
let exportStub;
let filenameStub;
let fsStub;
before(function () {
models.init();
});
afterEach(function () {
sinon.restore();
});
beforeEach(function () {
exportStub = sinon.stub(exporter, 'doExport').resolves();
filenameStub = sinon.stub(exporter, 'fileName').resolves('test');
fsStub = sinon.stub(fs, 'writeFile').resolves();
});
it('should create a backup JSON file', function (done) {
dbBackup.backup().then(function () {
exportStub.calledOnce.should.be.true();
filenameStub.calledOnce.should.be.true();
fsStub.calledOnce.should.be.true();
done();
}).catch(done);
});
});