Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matthanley authored and ErisDS committed May 20, 2022
1 parent f64577b commit 3471f6c
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 30 deletions.
4 changes: 2 additions & 2 deletions test/regression/api/admin/db.test.js
Expand Up @@ -52,8 +52,8 @@ describe('DB API (canary)', function () {
should.exist(jsonResponse.db);
jsonResponse.db.should.have.length(1);

// NOTE: 11 default tables + 1 from include parameters
Object.keys(jsonResponse.db[0].data).length.should.eql(12);
// NOTE: 16 default tables + 1 from include parameters
Object.keys(jsonResponse.db[0].data).length.should.eql(16);
});
});

Expand Down
80 changes: 52 additions & 28 deletions test/unit/server/data/exporter/index.test.js
Expand Up @@ -39,8 +39,8 @@ describe('Exporter', function () {

it('should try to export all the correct tables (without excluded)', function (done) {
exporter.doExport().then(function (exportData) {
// NOTE: 11 default tables
const expectedCallCount = 11;
// NOTE: 15 default tables
const expectedCallCount = 15;

should.exist(exportData);

Expand All @@ -52,17 +52,30 @@ describe('Exporter', function () {
knexMock.callCount.should.eql(expectedCallCount);
queryMock.select.callCount.should.have.eql(expectedCallCount);

knexMock.getCall(0).args[0].should.eql('newsletters');
knexMock.getCall(1).args[0].should.eql('posts');
knexMock.getCall(2).args[0].should.eql('posts_meta');
knexMock.getCall(3).args[0].should.eql('users');
knexMock.getCall(4).args[0].should.eql('posts_authors');
knexMock.getCall(5).args[0].should.eql('roles');
knexMock.getCall(6).args[0].should.eql('roles_users');
knexMock.getCall(7).args[0].should.eql('settings');
knexMock.getCall(8).args[0].should.eql('tags');
knexMock.getCall(9).args[0].should.eql('posts_tags');
knexMock.getCall(10).args[0].should.eql('custom_theme_settings');
let expectedTables = [
'posts',
'posts_authors',
'posts_meta',
'posts_tags',
'roles',
'roles_users',
'settings',
'custom_theme_settings',
'tags',
'users',
'products',
'stripe_products',
'stripe_prices',
'posts_products',
'newsletters'
];

for (let call = 0; call < expectedCallCount; call++) {
const arg = knexMock.getCall(call).args[0];
arg.should.be.equalOneOf(expectedTables);
expectedTables = expectedTables.filter(item => item !== arg);
}
expectedTables.should.be.empty();

done();
}).catch(done);
Expand All @@ -72,8 +85,8 @@ describe('Exporter', function () {
const include = ['mobiledoc_revisions', 'email_recipients'];

exporter.doExport({include}).then(function (exportData) {
// NOTE: 11 default tables + 2 includes
const expectedCallCount = 13;
// NOTE: 15 default tables + 2 includes
const expectedCallCount = 17;

should.exist(exportData);

Expand All @@ -86,19 +99,30 @@ describe('Exporter', function () {
knexMock.callCount.should.eql(expectedCallCount);
queryMock.select.callCount.should.have.eql(expectedCallCount);

knexMock.getCall(0).args[0].should.eql('newsletters');
knexMock.getCall(1).args[0].should.eql('posts');
knexMock.getCall(2).args[0].should.eql('posts_meta');
knexMock.getCall(3).args[0].should.eql('users');
knexMock.getCall(4).args[0].should.eql('posts_authors');
knexMock.getCall(5).args[0].should.eql('roles');
knexMock.getCall(6).args[0].should.eql('roles_users');
knexMock.getCall(7).args[0].should.eql('settings');
knexMock.getCall(8).args[0].should.eql('tags');
knexMock.getCall(9).args[0].should.eql('posts_tags');
knexMock.getCall(10).args[0].should.eql('mobiledoc_revisions');
knexMock.getCall(11).args[0].should.eql('email_recipients');
knexMock.getCall(12).args[0].should.eql('custom_theme_settings');
let expectedTables = [
'posts',
'posts_authors',
'posts_meta',
'posts_tags',
'roles',
'roles_users',
'settings',
'custom_theme_settings',
'tags',
'users',
'products',
'stripe_products',
'stripe_prices',
'posts_products',
'newsletters'
].concat(include);

for (let call = 0; call < expectedCallCount; call++) {
const arg = knexMock.getCall(call).args[0];
arg.should.be.equalOneOf(expectedTables);
expectedTables = expectedTables.filter(item => item !== arg);
}
expectedTables.should.be.empty();

done();
}).catch(done);
Expand Down
4 changes: 4 additions & 0 deletions test/utils/fixtures/export/body-generator.js
Expand Up @@ -146,10 +146,14 @@ const exportedBodyLatest = () => {
posts: [],
posts_authors: [],
posts_meta: [],
posts_products: [],
posts_tags: [],
products: [],
roles: [],
roles_users: [],
settings: [],
stripe_prices: [],
stripe_products: [],
tags: [],
users: []
}
Expand Down

0 comments on commit 3471f6c

Please sign in to comment.