Skip to content

Commit

Permalink
#60: test case for retrieving deliveryProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Apr 15, 2024
1 parent ebffd18 commit 9ea07ec
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/resources/9999999/deliveryProfile/get-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"key": "Default",
"createdDate": "2021-06-21T17:55:00Z",
"lastUpdated": "2021-06-21T17:55:00Z",
"name": "Default",
"description": "Account defaults"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"startIndex": 0,
"itemsPerPage": 50,
"totalResults": 1,
"entry": [
{
"id": "ejQ1Y2Q5SzVFZXU0UHZRRFE4bFptQTo0ODow",
"key": "Default",
"createdDate": "2021-06-21T17:55:00Z",
"lastUpdated": "2021-06-21T17:55:00Z",
"name": "Default",
"description": "Account defaults"
}
]
}
45 changes: 45 additions & 0 deletions test/type.deliveryProfile.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import * as chai from 'chai';
const assert = chai.assert;

import chaiFiles from 'chai-files';
import cache from '../lib/util/cache.js';
import * as testUtils from './utils.js';
import handler from '../lib/index.js';
chai.use(chaiFiles);

describe('type: deliveryProfile', () => {
beforeEach(() => {
testUtils.mockSetup();
});

afterEach(() => {
testUtils.mockReset();
});

describe('Retrieve ================', () => {
it('Should retrieve a deliveryProfile', async () => {
// WHEN
await handler.retrieve('testInstance/testBU', ['deliveryProfile']);
// THEN
assert.equal(process.exitCode, 0, 'retrieve should not have thrown an error');
// get results from cache
const result = cache.getCache();
assert.equal(
result.deliveryProfile ? Object.keys(result.deliveryProfile).length : 0,
1,
'only one deliveryProfile expected'
);
assert.deepEqual(
await testUtils.getActualJson('Default', 'deliveryProfile'),
await testUtils.getExpectedJson('9999999', 'deliveryProfile', 'get'),
'returned JSON was not equal expected'
);
assert.equal(
testUtils.getAPIHistoryLength(),
1,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
});
});
});

0 comments on commit 9ea07ec

Please sign in to comment.