Ghost/core/test/unit/export_spec.js

58 lines
1.6 KiB
JavaScript
Raw Normal View History

2013-06-16 00:52:03 +04:00
/*globals describe, beforeEach, it*/
var _ = require("underscore"),
should = require('should'),
when = require('when'),
sinon = require('sinon'),
helpers = require('./helpers'),
exporter = require('../../server/data/export'),
Exporter001 = require('../../server/data/export/001'),
errors = require('../../server/errorHandling');
describe("Export", function () {
should.exist(exporter);
beforeEach(function (done) {
helpers.resetData().then(function () {
done();
}, done);
});
2013-06-16 00:52:03 +04:00
it("resolves 001", function (done) {
var exportStub = sinon.stub(Exporter001, "exportData", function () {
return when.resolve();
2013-06-16 00:52:03 +04:00
});
exporter("001").then(function () {
exportStub.called.should.equal(true);
2013-06-16 00:52:03 +04:00
exportStub.restore();
2013-06-16 00:52:03 +04:00
done();
}).then(null, done);
});
2013-06-16 00:52:03 +04:00
describe("001", function () {
2013-06-16 00:52:03 +04:00
should.exist(Exporter001);
2013-06-16 00:52:03 +04:00
it("exports data", function (done) {
exporter("001").then(function (exportData) {
var tables = ['posts', 'users', 'roles', 'roles_users', 'permissions', 'permissions_roles', 'settings'];
2013-06-16 00:52:03 +04:00
should.exist(exportData);
2013-06-16 00:52:03 +04:00
should.exist(exportData.meta);
should.exist(exportData.data);
2013-06-16 00:52:03 +04:00
exportData.meta.version.should.equal("001");
2013-06-16 00:52:03 +04:00
_.each(tables, function (name) {
should.exist(exportData.data[name]);
2013-06-16 00:52:03 +04:00
});
done();
}).then(null, done);
2013-06-16 00:52:03 +04:00
});
});
});