Skip to content

Commit

Permalink
#557: fix transactionalEmail RETRIEVE test
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Nov 30, 2022
1 parent b18e27d commit c563819
Showing 1 changed file with 78 additions and 8 deletions.
86 changes: 78 additions & 8 deletions test/transactionalEmail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ const chai = require('chai');
const chaiFiles = require('chai-files');
const assert = chai.assert;
chai.use(chaiFiles);
const expect = chai.expect;
const file = chaiFiles.file;
// const dir = chaiFiles.dir;
const cache = require('../lib/util/cache');
const testUtils = require('./utils');
const handler = require('../lib/index');
Expand All @@ -30,14 +27,87 @@ describe('transactionalEmail', () => {
'only one transactionalEmail expected'
);
assert.deepEqual(
await testUtils.getActualJson('testExisting_tsms', 'transactionalEmail'),
await testUtils.getActualJson('testExisting_temail', 'transactionalEmail'),
await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'get'),
'returned JSON was not equal expected'
);
expect(
file(testUtils.getActualFile('testExisting_tsms', 'transactionalEmail', 'amp'))
).to.equal(
file(testUtils.getExpectedFile('9999999', 'transactionalEmail', 'get', 'amp'))
assert.equal(
Object.values(testUtils.getAPIHistory()).flat().length,
12,
'Unexpected number of requests made'
);
return;
});
});
describe('Deploy ================', () => {
beforeEach(() => {
testUtils.mockSetup(true);
});
it('Should create & upsert a transactionalEmail', async () => {
// WHEN
await handler.deploy('testInstance/testBU', ['transactionalEmail']);
// THEN
// get results from cache
const result = cache.getCache();
assert.equal(
result.transactionalEmail ? Object.keys(result.transactionalEmail).length : 0,
2,
'two transactionalEmails expected'
);
// confirm created item
assert.deepEqual(
await testUtils.getActualJson('testNew_temail', 'transactionalEmail'),
await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'post'),
'returned JSON was not equal expected for insert transactionalEmail'
);
// confirm updated item
assert.deepEqual(
await testUtils.getActualJson('testExisting_temail', 'transactionalEmail'),
await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'patch'),
'returned JSON was not equal expected for update transactionalEmail'
);
// check number of API calls
assert.equal(
Object.values(testUtils.getAPIHistory()).flat().length,
5,
'Unexpected number of requests made'
);
return;
});
});
describe('Templating ================', () => {
// it.skip('Should create a transactionalEmail template via retrieveAsTemplate and build it');
it('Should create a transactionalEmail template via buildTemplate and build it', async () => {
// download first before we test buildTemplate
await handler.retrieve('testInstance/testBU', ['transactionalEmail']);
// buildTemplate
const result = await handler.buildTemplate(
'testInstance/testBU',
'transactionalEmail',
['testExisting_temail'],
'testSourceMarket'
);
assert.equal(
result.transactionalEmail ? Object.keys(result.transactionalEmail).length : 0,
1,
'only one transactionalEmail expected'
);
assert.deepEqual(
await testUtils.getActualTemplateJson('testExisting_temail', 'transactionalEmail'),
await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'template'),
'returned template JSON was not equal expected'
);
// buildDefinition
await handler.buildDefinition(
'testInstance/testBU',
'transactionalEmail',
'testExisting_temail',
'testTargetMarket'
);
assert.deepEqual(
await testUtils.getActualDeployJson('testExisting_temail', 'transactionalEmail'),
await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'build'),
'returned deployment JSON was not equal expected'
);
assert.equal(
Object.values(testUtils.getAPIHistory()).flat().length,
Expand Down

0 comments on commit c563819

Please sign in to comment.