Fixed exporter tests using should.have.keys assertion

refs https://github.com/TryGhost/Team/issues/555
refs 080a8fc082

-  The `have.keys` assertion was not doing strict comparison neither provided any useful output when changed to `have.only.keys`.
- Rewrote the tests to use manual assertion through array comparison which checks exactly what it's supposed to and gives a visual diff in case there are any missing/extra properties in config
This commit is contained in:
Naz 2021-03-25 13:22:34 +13:00
parent 080a8fc082
commit 74cdbadedb
2 changed files with 7 additions and 5 deletions

View File

@ -51,9 +51,9 @@ describe('DB API', function () {
const dataKeys = Object.keys(exportedBodyLatest().db[0].data);
Object.keys(jsonResponse.db[0].data).length.should.eql(28);
Object.keys(jsonResponse.db[0].data).length.should.eql(dataKeys.length);
jsonResponse.db[0].data.should.have.only.keys(...dataKeys);
// NOTE: using `Object.keys` here instead of `should.have.only.keys` assertion
// because when `have.only.keys` fails there's no useful diff
Object.keys(jsonResponse.db[0].data).should.eql(dataKeys);
});
it('Can delete all content', async function () {

View File

@ -66,8 +66,10 @@ describe('Exporter', function () {
should.exist(exportData.meta);
should.exist(exportData.data);
exportData.data.should.have.only.keys(...tables);
exportData.data.should.have.keys(...Object.keys(exportedBodyLatest().db[0].data));
// NOTE: using `Object.keys` here instead of `should.have.only.keys` assertion
// because when `have.only.keys` fails there's no useful diff
Object.keys(exportData.data).should.eql(tables);
Object.keys(exportData.data).should.containDeep(Object.keys(exportedBodyLatest().db[0].data));
exportData.meta.version.should.equal(ghostVersion.full);
// excludes table should contain no data