diff --git a/test/general.test.js b/test/general.test.js index 686e7c5a5..dd29dfb2b 100644 --- a/test/general.test.js +++ b/test/general.test.js @@ -6,7 +6,6 @@ import chaiFiles from 'chai-files'; import * as testUtils from './utils.js'; import handler from '../lib/index.js'; chai.use(chaiFiles); -const file = chaiFiles.file; describe('GENERAL', () => { beforeEach(() => { @@ -343,8 +342,8 @@ describe('GENERAL', () => { 'returned template JSON of retrieveAsTemplate was not equal expected' ); expect( - file(testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'template', 'sql'))); + await testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'template', 'sql')); // *** buildDefinition *** const definitionResult = await handler.buildDefinition( @@ -385,8 +384,8 @@ describe('GENERAL', () => { 'returned deployment JSON was not equal expected' ); expect( - file(testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'build', 'sql'))); + await testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'build', 'sql')); assert.equal( testUtils.getAPIHistoryLength() - expectedApiCallsRetrieve, @@ -445,8 +444,8 @@ describe('GENERAL', () => { 'returned template JSON of retrieveAsTemplate was not equal expected' ); expect( - file(testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'template', 'sql'))); + await testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'template', 'sql')); // *** buildDefinition *** @@ -476,8 +475,8 @@ describe('GENERAL', () => { 'returned deployment JSON was not equal expected' ); expect( - file(testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'build', 'sql'))); + await testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'build', 'sql')); assert.equal( testUtils.getAPIHistoryLength() - expectedApiCallsRetrieve, @@ -537,8 +536,8 @@ describe('GENERAL', () => { 'returned template JSON of retrieveAsTemplate was not equal expected' ); expect( - file(testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'template', 'sql'))); + await testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'template', 'sql')); // *** buildDefinitionBulk *** @@ -580,23 +579,19 @@ describe('GENERAL', () => { // check if files were also created for other BU-market combos // testBU: testSourceMarket expect( - file( - testUtils.getActualDeployFile( - 'testExisting_automation', - 'automation', - 'json' - ) + await testUtils.getActualDeployFile( + 'testExisting_automation', + 'automation', + 'json' ) ).to.exist; // _ParentBU_: testTargetMarket expect( - file( - testUtils.getActualDeployFile( - 'testTemplated_automation', - 'automation', - 'json', - '_ParentBU_' - ) + await testUtils.getActualDeployFile( + 'testTemplated_automation', + 'automation', + 'json', + '_ParentBU_' ) ).to.exist; @@ -634,34 +629,30 @@ describe('GENERAL', () => { 'returned deployment JSON was not equal expected' ); expect( - file(testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'build', 'sql'))); + await testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'build', 'sql')); // check if files were also created for other BU-market combos // testBU: testSourceMarket - expect(file(testUtils.getActualDeployFile('testExisting_query', 'query', 'json'))) + expect(await testUtils.getActualDeployFile('testExisting_query', 'query', 'json')) .to.exist; - expect(file(testUtils.getActualDeployFile('testExisting_query', 'query', 'sql'))).to + expect(await testUtils.getActualDeployFile('testExisting_query', 'query', 'sql')).to .exist; // _ParentBU_: testTargetMarket expect( - file( - testUtils.getActualDeployFile( - 'testTemplated_query', - 'query', - 'json', - '_ParentBU_' - ) + await testUtils.getActualDeployFile( + 'testTemplated_query', + 'query', + 'json', + '_ParentBU_' ) ).to.exist; expect( - file( - testUtils.getActualDeployFile( - 'testTemplated_query', - 'query', - 'sql', - '_ParentBU_' - ) + await testUtils.getActualDeployFile( + 'testTemplated_query', + 'query', + 'sql', + '_ParentBU_' ) ).to.exist; @@ -728,8 +719,8 @@ describe('GENERAL', () => { 'returned template JSON of retrieveAsTemplate was not equal expected' ); expect( - file(testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'template', 'sql'))); + await testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'template', 'sql')); // *** buildDefinitionBulk chained *** const definitionResult = await handler.buildDefinitionBulk( @@ -780,23 +771,19 @@ describe('GENERAL', () => { // check if files were also created for other BU-market combos // testBU: testSourceMarket expect( - file( - testUtils.getActualDeployFile( - 'testExisting_automation', - 'automation', - 'json' - ) + await testUtils.getActualDeployFile( + 'testExisting_automation', + 'automation', + 'json' ) ).to.exist; // _ParentBU_: testTargetMarket expect( - file( - testUtils.getActualDeployFile( - 'testTemplated_automation', - 'automation', - 'json', - '_ParentBU_' - ) + await testUtils.getActualDeployFile( + 'testTemplated_automation', + 'automation', + 'json', + '_ParentBU_' ) ).to.exist; @@ -834,34 +821,30 @@ describe('GENERAL', () => { 'returned deployment JSON was not equal expected' ); expect( - file(testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'build', 'sql'))); + await testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'build', 'sql')); // check if files were also created for other BU-market combos // testBU: testSourceMarket - expect(file(testUtils.getActualDeployFile('testExisting_query', 'query', 'json'))) + expect(await testUtils.getActualDeployFile('testExisting_query', 'query', 'json')) .to.exist; - expect(file(testUtils.getActualDeployFile('testExisting_query', 'query', 'sql'))).to + expect(await testUtils.getActualDeployFile('testExisting_query', 'query', 'sql')).to .exist; // _ParentBU_: testTargetMarket expect( - file( - testUtils.getActualDeployFile( - 'testTemplated_query', - 'query', - 'json', - '_ParentBU_' - ) + await testUtils.getActualDeployFile( + 'testTemplated_query', + 'query', + 'json', + '_ParentBU_' ) ).to.exist; expect( - file( - testUtils.getActualDeployFile( - 'testTemplated_query', - 'query', - 'sql', - '_ParentBU_' - ) + await testUtils.getActualDeployFile( + 'testTemplated_query', + 'query', + 'sql', + '_ParentBU_' ) ).to.exist; diff --git a/test/type.asset.test.js b/test/type.asset.test.js index 1ddad5030..5d9f4a13d 100644 --- a/test/type.asset.test.js +++ b/test/type.asset.test.js @@ -158,7 +158,7 @@ describe('type: asset', () => { 'returned metadata was not equal expected' ); expect(file(getActualFile('mcdev-issue-1157', 'asset', 'block', 'html'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'asset', 'block-1157-retrieve', 'html')) + await testUtils.getExpectedFile('9999999', 'asset', 'block-1157-retrieve', 'html') ); assert.deepEqual( @@ -335,13 +335,11 @@ describe('type: asset', () => { 'views.html.content' ) ).to.equal( - file( - testUtils.getExpectedFile( - '9999999', - 'asset', - 'template-templatebasedemail', - 'html' - ) + await testUtils.getExpectedFile( + '9999999', + 'asset', + 'template-templatebasedemail', + 'html' ) ); // THEN @@ -371,13 +369,11 @@ describe('type: asset', () => { 'views.html.content' ) ).to.equal( - file( - testUtils.getExpectedFile( - '9999999', - 'asset', - 'build-templatebasedemail', - 'html' - ) + await testUtils.getExpectedFile( + '9999999', + 'asset', + 'build-templatebasedemail', + 'html' ) ); diff --git a/test/type.automation.test.js b/test/type.automation.test.js index 96cc86460..ce76ca652 100644 --- a/test/type.automation.test.js +++ b/test/type.automation.test.js @@ -7,7 +7,6 @@ import cache from '../lib/util/cache.js'; import * as testUtils from './utils.js'; import handler from '../lib/index.js'; chai.use(chaiFiles); -const file = chaiFiles.file; describe('type: automation', () => { beforeEach(() => { @@ -38,14 +37,12 @@ describe('type: automation', () => { 'returned metadata was not equal expected' ); // check if MD file was created and equals expectations - expect(file(testUtils.getActualDoc('testExisting_automation', 'automation'))).to.equal( - file( - testUtils.getExpectedFile( - '9999999', - 'automation', - 'retrieve-testExisting_automation', - 'md' - ) + expect(await testUtils.getActualDoc('testExisting_automation', 'automation')).to.equal( + await testUtils.getExpectedFile( + '9999999', + 'automation', + 'retrieve-testExisting_automation', + 'md' ) ); assert.equal( @@ -101,26 +98,22 @@ describe('type: automation', () => { 'returned metadata was not equal expected for update' ); // check if MD file was created and equals expectations - expect(file(testUtils.getActualDoc('testExisting_automation', 'automation'))).to.equal( - file( - testUtils.getExpectedFile( - '9999999', - 'automation', - 'update-testExisting_automation', - 'md' - ) + expect(await testUtils.getActualDoc('testExisting_automation', 'automation')).to.equal( + await testUtils.getExpectedFile( + '9999999', + 'automation', + 'update-testExisting_automation', + 'md' ) ); // check if MD file was created and equals expectations - expect(file(testUtils.getActualDoc('testNew_automation', 'automation'))).to.equal( - file( - testUtils.getExpectedFile( - '9999999', - 'automation', - 'create-testNew_automation', - 'md' - ) + expect(await testUtils.getActualDoc('testNew_automation', 'automation')).to.equal( + await testUtils.getExpectedFile( + '9999999', + 'automation', + 'create-testNew_automation', + 'md' ) ); @@ -183,14 +176,12 @@ describe('type: automation', () => { 'returned metadata was not equal expected for update' ); // check if MD file was created and equals expectations - expect(file(testUtils.getActualDoc('testExisting_automation', 'automation'))).to.equal( - file( - testUtils.getExpectedFile( - '9999999', - 'automation', - 'update-testExisting_automation', - 'md' - ) + expect(await testUtils.getActualDoc('testExisting_automation', 'automation')).to.equal( + await testUtils.getExpectedFile( + '9999999', + 'automation', + 'update-testExisting_automation', + 'md' ) ); @@ -252,14 +243,12 @@ describe('type: automation', () => { 'returned metadata was not equal expected for update' ); // check if MD file was created and equals expectations - expect(file(testUtils.getActualDoc('testExisting_automation', 'automation'))).to.equal( - file( - testUtils.getExpectedFile( - '9999999', - 'automation', - 'update-testExisting_automation', - 'md' - ) + expect(await testUtils.getActualDoc('testExisting_automation', 'automation')).to.equal( + await testUtils.getExpectedFile( + '9999999', + 'automation', + 'update-testExisting_automation', + 'md' ) ); @@ -340,11 +329,9 @@ describe('type: automation', () => { 'returned metadata was not equal expected for update automation' ); expect( - file( - testUtils.getActualDoc( - 'testExisting_automation_fixedKey_scheduled', - 'automation' - ) + await testUtils.getActualDoc( + 'testExisting_automation_fixedKey_scheduled', + 'automation' ) ).to.exist; // check number of API calls @@ -386,11 +373,9 @@ describe('type: automation', () => { 'returned metadata was not equal expected for update automation' ); expect( - file( - testUtils.getActualDoc( - 'testExisting_automation_fixedKey_scheduled', - 'automation' - ) + await testUtils.getActualDoc( + 'testExisting_automation_fixedKey_scheduled', + 'automation' ) ).to.exist; // check number of API calls @@ -432,11 +417,9 @@ describe('type: automation', () => { 'returned metadata was not equal expected for update automation' ); expect( - file( - testUtils.getActualDoc( - 'testExisting_automation_fixedKey_scheduled', - 'automation' - ) + await testUtils.getActualDoc( + 'testExisting_automation_fixedKey_scheduled', + 'automation' ) ).to.exist; // check number of API calls @@ -478,8 +461,9 @@ describe('type: automation', () => { 'returned metadata was not equal expected for update automation' ); expect( - file( - testUtils.getActualDoc('testExisting_automation_fixedKey_paused', 'automation') + await testUtils.getActualDoc( + 'testExisting_automation_fixedKey_paused', + 'automation' ) ).to.exist; // check number of API calls @@ -521,8 +505,9 @@ describe('type: automation', () => { 'returned metadata was not equal expected for update automation' ); expect( - file( - testUtils.getActualDoc('testExisting_automation_fixedKey_paused', 'automation') + await testUtils.getActualDoc( + 'testExisting_automation_fixedKey_paused', + 'automation' ) ).to.exist; // check number of API calls @@ -564,8 +549,9 @@ describe('type: automation', () => { 'returned metadata was not equal expected for update automation' ); expect( - file( - testUtils.getActualDoc('testExisting_automation_fixedKey_paused', 'automation') + await testUtils.getActualDoc( + 'testExisting_automation_fixedKey_paused', + 'automation' ) ).to.exist; // check number of API calls diff --git a/test/type.dataExtension.test.js b/test/type.dataExtension.test.js index d53101ed8..805c9a83a 100644 --- a/test/type.dataExtension.test.js +++ b/test/type.dataExtension.test.js @@ -7,7 +7,6 @@ import cache from '../lib/util/cache.js'; import * as testUtils from './utils.js'; import handler from '../lib/index.js'; chai.use(chaiFiles); -const file = chaiFiles.file; describe('type: dataExtension', () => { beforeEach(() => { @@ -39,9 +38,9 @@ describe('type: dataExtension', () => { ); // check if MD file was created and equals expectations expect( - file(testUtils.getActualDoc('testExisting_dataExtension', 'dataExtension')) + await testUtils.getActualDoc('testExisting_dataExtension', 'dataExtension') ).to.equal( - file(testUtils.getExpectedFile('9999999', 'dataExtension', 'retrieve', 'md')) + await testUtils.getExpectedFile('9999999', 'dataExtension', 'retrieve', 'md') ); assert.equal( @@ -76,15 +75,13 @@ describe('type: dataExtension', () => { ); // check if MD file was created and equals expectations expect( - file( - testUtils.getActualDoc( - 'testExisting_dataExtensionShared', - 'dataExtension', - '_ParentBU_' - ) + await testUtils.getActualDoc( + 'testExisting_dataExtensionShared', + 'dataExtension', + '_ParentBU_' ) ).to.equal( - file(testUtils.getExpectedFile('1111111', 'dataExtension', 'retrieve', 'md')) + await testUtils.getExpectedFile('1111111', 'dataExtension', 'retrieve', 'md') ); assert.equal( diff --git a/test/type.mobileKeyword.test.js b/test/type.mobileKeyword.test.js index 0f10856df..b179a6338 100644 --- a/test/type.mobileKeyword.test.js +++ b/test/type.mobileKeyword.test.js @@ -7,7 +7,6 @@ import cache from '../lib/util/cache.js'; import * as testUtils from './utils.js'; import handler from '../lib/index.js'; chai.use(chaiFiles); -const file = chaiFiles.file; describe('type: mobileKeyword', () => { beforeEach(() => { @@ -40,14 +39,12 @@ describe('type: mobileKeyword', () => { 'saved JSON was not equal expected' ); expect( - file( - testUtils.getActualFile( - '4912312345678.TESTEXISTING_KEYWORD', - 'mobileKeyword', - 'amp' - ) + await testUtils.getActualFile( + '4912312345678.TESTEXISTING_KEYWORD', + 'mobileKeyword', + 'amp' ) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'mobileKeyword', 'get', 'amp'))); + ).to.equal(await testUtils.getExpectedFile('9999999', 'mobileKeyword', 'get', 'amp')); assert.equal( testUtils.getAPIHistoryLength(), 2, @@ -85,11 +82,13 @@ describe('type: mobileKeyword', () => { 'returned JSON was not equal expected for insert mobileKeyword' ); expect( - file( - testUtils.getActualFile('4912312345678.TESTNEW_KEYWORD', 'mobileKeyword', 'amp') + await testUtils.getActualFile( + '4912312345678.TESTNEW_KEYWORD', + 'mobileKeyword', + 'amp' ) ).to.equal( - file(testUtils.getExpectedFile('9999999', 'mobileKeyword', 'post-create', 'amp')) + await testUtils.getExpectedFile('9999999', 'mobileKeyword', 'post-create', 'amp') ); // confirm updated item @@ -152,15 +151,13 @@ describe('type: mobileKeyword', () => { 'returned template JSON was not equal expected' ); expect( - file( - testUtils.getActualTemplateFile( - '4912312345678.TESTEXISTING_KEYWORD', - 'mobileKeyword', - 'amp' - ) + await testUtils.getActualTemplateFile( + '4912312345678.TESTEXISTING_KEYWORD', + 'mobileKeyword', + 'amp' ) ).to.equal( - file(testUtils.getExpectedFile('9999999', 'mobileKeyword', 'template', 'amp')) + await testUtils.getExpectedFile('9999999', 'mobileKeyword', 'template', 'amp') ); assert.equal( testUtils.getAPIHistoryLength(), @@ -196,15 +193,13 @@ describe('type: mobileKeyword', () => { 'returned template JSON was not equal expected' ); expect( - file( - testUtils.getActualTemplateFile( - '4912312345678.TESTEXISTING_KEYWORD', - 'mobileKeyword', - 'amp' - ) + await testUtils.getActualTemplateFile( + '4912312345678.TESTEXISTING_KEYWORD', + 'mobileKeyword', + 'amp' ) ).to.equal( - file(testUtils.getExpectedFile('9999999', 'mobileKeyword', 'template', 'amp')) + await testUtils.getExpectedFile('9999999', 'mobileKeyword', 'template', 'amp') ); // buildDefinition @@ -224,14 +219,12 @@ describe('type: mobileKeyword', () => { 'returned deployment JSON was not equal expected' ); expect( - file( - testUtils.getActualDeployFile( - '4912312345678.TESTTEMPLATED_KEYWORD', - 'mobileKeyword', - 'amp' - ) + await testUtils.getActualDeployFile( + '4912312345678.TESTTEMPLATED_KEYWORD', + 'mobileKeyword', + 'amp' ) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'mobileKeyword', 'build', 'amp'))); + ).to.equal(await testUtils.getExpectedFile('9999999', 'mobileKeyword', 'build', 'amp')); assert.equal( testUtils.getAPIHistoryLength(), diff --git a/test/type.mobileMessage.test.js b/test/type.mobileMessage.test.js index 8823496d9..37ff4b040 100644 --- a/test/type.mobileMessage.test.js +++ b/test/type.mobileMessage.test.js @@ -7,7 +7,6 @@ import cache from '../lib/util/cache.js'; import * as testUtils from './utils.js'; import handler from '../lib/index.js'; chai.use(chaiFiles); -const file = chaiFiles.file; describe('type: mobileMessage', () => { beforeEach(() => { @@ -36,8 +35,8 @@ describe('type: mobileMessage', () => { await testUtils.getExpectedJson('9999999', 'mobileMessage', 'get'), 'saved JSON was not equal expected' ); - expect(file(testUtils.getActualFile('NTIzOjc4OjA', 'mobileMessage', 'amp'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'mobileMessage', 'get', 'amp')) + expect(await testUtils.getActualFile('NTIzOjc4OjA', 'mobileMessage', 'amp')).to.equal( + await testUtils.getExpectedFile('9999999', 'mobileMessage', 'get', 'amp') ); assert.equal( testUtils.getAPIHistoryLength(), @@ -71,8 +70,8 @@ describe('type: mobileMessage', () => { await testUtils.getExpectedJson('9999999', 'mobileMessage', 'post-create'), 'returned JSON was not equal expected for insert mobileMessage' ); - expect(file(testUtils.getActualFile('NTQ3Ojc4OjA', 'mobileMessage', 'amp'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'mobileMessage', 'post-create', 'amp')) + expect(await testUtils.getActualFile('NTQ3Ojc4OjA', 'mobileMessage', 'amp')).to.equal( + await testUtils.getExpectedFile('9999999', 'mobileMessage', 'post-create', 'amp') ); // confirm updated item @@ -81,8 +80,8 @@ describe('type: mobileMessage', () => { await testUtils.getExpectedJson('9999999', 'mobileMessage', 'post-update'), // watch out - mobileMessage api wants put instead of patch for updates 'returned JSON was not equal expected for update mobileMessage' ); - expect(file(testUtils.getActualFile('NTIzOjc4OjA', 'mobileMessage', 'amp'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'mobileMessage', 'post-update', 'amp')) + expect(await testUtils.getActualFile('NTIzOjc4OjA', 'mobileMessage', 'amp')).to.equal( + await testUtils.getExpectedFile('9999999', 'mobileMessage', 'post-update', 'amp') ); // check number of API calls @@ -132,9 +131,9 @@ describe('type: mobileMessage', () => { 'returned template JSON was not equal expected' ); expect( - file(testUtils.getActualTemplateFile('NTIzOjc4OjA', 'mobileMessage', 'amp')) + await testUtils.getActualTemplateFile('NTIzOjc4OjA', 'mobileMessage', 'amp') ).to.equal( - file(testUtils.getExpectedFile('9999999', 'mobileMessage', 'template', 'amp')) + await testUtils.getExpectedFile('9999999', 'mobileMessage', 'template', 'amp') ); // buildDefinition @@ -151,8 +150,8 @@ describe('type: mobileMessage', () => { 'returned deployment JSON was not equal expected' ); expect( - file(testUtils.getActualDeployFile('NTIzOjc4OjA', 'mobileMessage', 'amp')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'mobileMessage', 'build', 'amp'))); + await testUtils.getActualDeployFile('NTIzOjc4OjA', 'mobileMessage', 'amp') + ).to.equal(await testUtils.getExpectedFile('9999999', 'mobileMessage', 'build', 'amp')); assert.equal( testUtils.getAPIHistoryLength(), diff --git a/test/type.query.test.js b/test/type.query.test.js index 5ef5e0900..ff2dce40a 100644 --- a/test/type.query.test.js +++ b/test/type.query.test.js @@ -7,7 +7,6 @@ import cache from '../lib/util/cache.js'; import * as testUtils from './utils.js'; import handler from '../lib/index.js'; chai.use(chaiFiles); -const file = chaiFiles.file; describe('type: query', () => { beforeEach(() => { @@ -37,8 +36,8 @@ describe('type: query', () => { await testUtils.getExpectedJson('9999999', 'query', 'get'), 'returned metadata with correct key was not equal expected' ); - expect(file(testUtils.getActualFile('testExisting_query', 'query', 'sql'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'query', 'get', 'sql')) + expect(await testUtils.getActualFile('testExisting_query', 'query', 'sql')).to.equal( + await testUtils.getExpectedFile('9999999', 'query', 'get', 'sql') ); // check if r__dataExtension_key was overwritten assert.deepEqual( @@ -72,8 +71,8 @@ describe('type: query', () => { await testUtils.getExpectedJson('9999999', 'query', 'get'), 'returned metadata was not equal expected' ); - expect(file(testUtils.getActualFile('testExisting_query', 'query', 'sql'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'query', 'get', 'sql')) + expect(await testUtils.getActualFile('testExisting_query', 'query', 'sql')).to.equal( + await testUtils.getExpectedFile('9999999', 'query', 'get', 'sql') ); assert.equal( testUtils.getAPIHistoryLength(), @@ -101,10 +100,10 @@ describe('type: query', () => { await testUtils.getExpectedJson('9999999', 'query', 'get'), 'returned metadata was not equal expected' ); - expect(file(testUtils.getActualFile('testExisting_query', 'query', 'sql'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'query', 'get', 'sql')) + expect(await testUtils.getActualFile('testExisting_query', 'query', 'sql')).to.equal( + await testUtils.getExpectedFile('9999999', 'query', 'get', 'sql') ); - expect(file(testUtils.getActualFile('testExisting_query2', 'query', 'sql'))).to.not + expect(await testUtils.getActualFile('testExisting_query2', 'query', 'sql')).to.not .exist; assert.equal( testUtils.getAPIHistoryLength(), @@ -128,9 +127,9 @@ describe('type: query', () => { '4 queries in cache expected' ); - expect(file(testUtils.getActualFile('testExisting_query', 'query', 'sql'))).to.not + expect(await testUtils.getActualFile('testExisting_query', 'query', 'sql')).to.not .exist; - expect(file(testUtils.getActualFile('testExisting_query2', 'query', 'sql'))).to.not + expect(await testUtils.getActualFile('testExisting_query2', 'query', 'sql')).to.not .exist; assert.equal( testUtils.getAPIHistoryLength(), @@ -175,8 +174,8 @@ describe('type: query', () => { await testUtils.getExpectedJson('9999999', 'query', 'post'), 'returned metadata was not equal expected for insert query' ); - expect(file(testUtils.getActualFile('testNew_query', 'query', 'sql'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'query', 'post', 'sql')) + expect(await testUtils.getActualFile('testNew_query', 'query', 'sql')).to.equal( + await testUtils.getExpectedFile('9999999', 'query', 'post', 'sql') ); // confirm updated item assert.deepEqual( @@ -184,8 +183,8 @@ describe('type: query', () => { await testUtils.getExpectedJson('9999999', 'query', 'patch'), 'returned metadata was not equal expected for insert query' ); - expect(file(testUtils.getActualFile('testExisting_query', 'query', 'sql'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'query', 'patch', 'sql')) + expect(await testUtils.getActualFile('testExisting_query', 'query', 'sql')).to.equal( + await testUtils.getExpectedFile('9999999', 'query', 'patch', 'sql') ); // check number of API calls assert.equal( @@ -216,8 +215,8 @@ describe('type: query', () => { await testUtils.getExpectedJson('9999999', 'query', 'patch'), 'returned metadata was not equal expected for insert query' ); - expect(file(testUtils.getActualFile('testExisting_query', 'query', 'sql'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'query', 'patch', 'sql')) + expect(await testUtils.getActualFile('testExisting_query', 'query', 'sql')).to.equal( + await testUtils.getExpectedFile('9999999', 'query', 'patch', 'sql') ); // check number of API calls assert.equal( @@ -281,8 +280,8 @@ describe('type: query', () => { 'returned metadata was not equal expected for update query' ); expect( - file(testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql'))); + await testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql')); // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), @@ -335,8 +334,8 @@ describe('type: query', () => { 'returned metadata was not equal expected for update query' ); expect( - file(testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql'))); + await testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql')); // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), @@ -389,9 +388,9 @@ describe('type: query', () => { 'returned metadata was not equal expected for update query' ); expect( - file(testUtils.getActualFile('testExisting_query_fixedKeys_DEV', 'query', 'sql')) + await testUtils.getActualFile('testExisting_query_fixedKeys_DEV', 'query', 'sql') ).to.equal( - file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeysSuffix', 'sql')) + await testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeysSuffix', 'sql') ); // check number of API calls assert.equal( @@ -505,8 +504,8 @@ describe('type: query', () => { 'returned metadata was not equal expected for update query' ); expect( - file(testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql'))); + await testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql')); // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), @@ -554,9 +553,9 @@ describe('type: query', () => { 'returned metadata was not equal expected for update query' ); expect( - file(testUtils.getActualFile('testExisting_query_fixedKeys_DEV', 'query', 'sql')) + await testUtils.getActualFile('testExisting_query_fixedKeys_DEV', 'query', 'sql') ).to.equal( - file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeysSuffix', 'sql')) + await testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeysSuffix', 'sql') ); // check number of API calls assert.equal( @@ -598,8 +597,8 @@ describe('type: query', () => { 'returned metadata was not equal expected for update query' ); expect( - file(testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql'))); + await testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql')); // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), @@ -636,8 +635,8 @@ describe('type: query', () => { 'returned metadata was not equal expected for update query' ); expect( - file(testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql'))); + await testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql')); // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), @@ -678,8 +677,8 @@ describe('type: query', () => { 'returned metadata was not equal expected for update query' ); expect( - file(testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql'))); + await testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql')); // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), @@ -715,8 +714,8 @@ describe('type: query', () => { 'returned metadata was not equal expected for update query' ); expect( - file(testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql'))); + await testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql')); // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), @@ -749,8 +748,8 @@ describe('type: query', () => { 'returned template JSON of retrieveAsTemplate was not equal expected' ); expect( - file(testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'template', 'sql'))); + await testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'template', 'sql')); // THEN await handler.buildDefinition( 'testInstance/testBU', @@ -766,8 +765,8 @@ describe('type: query', () => { 'returned deployment JSON was not equal expected' ); expect( - file(testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'build', 'sql'))); + await testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'build', 'sql')); assert.equal( testUtils.getAPIHistoryLength(), @@ -801,8 +800,8 @@ describe('type: query', () => { 'returned template JSON of buildTemplate was not equal expected' ); expect( - file(testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'template', 'sql'))); + await testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'template', 'sql')); // THEN await handler.buildDefinition( 'testInstance/testBU', @@ -818,8 +817,8 @@ describe('type: query', () => { 'returned deployment JSON was not equal expected' ); expect( - file(testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'build', 'sql'))); + await testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql') + ).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'build', 'sql')); assert.equal( testUtils.getAPIHistoryLength(), diff --git a/test/type.script.test.js b/test/type.script.test.js index c40cdcfb9..25745f0f5 100644 --- a/test/type.script.test.js +++ b/test/type.script.test.js @@ -7,7 +7,6 @@ import cache from '../lib/util/cache.js'; import * as testUtils from './utils.js'; import handler from '../lib/index.js'; chai.use(chaiFiles); -const file = chaiFiles.file; describe('type: script', () => { beforeEach(() => { @@ -46,10 +45,10 @@ describe('type: script', () => { await testUtils.getExpectedJson('9999999', 'script', 'get'), 'returned metadata with correct key was not equal expected' ); - expect(file(testUtils.getActualFile('testExisting_script', 'script', 'html'))).to.not + expect(await testUtils.getActualFile('testExisting_script', 'script', 'html')).to.not .exist; - expect(file(testUtils.getActualFile('testExisting_script', 'script', 'ssjs'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'script', 'get', 'ssjs')) + expect(await testUtils.getActualFile('testExisting_script', 'script', 'ssjs')).to.equal( + await testUtils.getExpectedFile('9999999', 'script', 'get', 'ssjs') ); // test with no script tag @@ -59,12 +58,12 @@ describe('type: script', () => { 'returned metadata was not equal expected' ); expect( - file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'html')) + await testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'html') ).to.equal( - file(testUtils.getExpectedFile('9999999', 'script', 'get_noScriptTag', 'html')) + await testUtils.getExpectedFile('9999999', 'script', 'get_noScriptTag', 'html') ); expect( - file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'ssjs')) + await testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'ssjs') ).to.not.exist; // test with ampscript @@ -74,11 +73,11 @@ describe('type: script', () => { 'returned metadata was not equal expected' ); expect( - file(testUtils.getActualFile('testExisting_script_ampscript', 'script', 'html')) + await testUtils.getActualFile('testExisting_script_ampscript', 'script', 'html') ).to.equal( - file(testUtils.getExpectedFile('9999999', 'script', 'get_ampscript', 'html')) + await testUtils.getExpectedFile('9999999', 'script', 'get_ampscript', 'html') ); - expect(file(testUtils.getActualFile('testExisting_script_ampscript', 'script', 'ssjs'))) + expect(await testUtils.getActualFile('testExisting_script_ampscript', 'script', 'ssjs')) .to.not.exist; // test with mixed code (ampscript inside of ssjs) @@ -88,12 +87,12 @@ describe('type: script', () => { 'returned metadata was not equal expected' ); expect( - file(testUtils.getActualFile('testExisting_script_ampincluded', 'script', 'html')) + await testUtils.getActualFile('testExisting_script_ampincluded', 'script', 'html') ).to.not.exist; expect( - file(testUtils.getActualFile('testExisting_script_ampincluded', 'script', 'ssjs')) + await testUtils.getActualFile('testExisting_script_ampincluded', 'script', 'ssjs') ).to.equal( - file(testUtils.getExpectedFile('9999999', 'script', 'get_ampincluded', 'ssjs')) + await testUtils.getExpectedFile('9999999', 'script', 'get_ampincluded', 'ssjs') ); // test with mixed code (ssjs and ampscript side-by-side) @@ -103,9 +102,9 @@ describe('type: script', () => { 'returned metadata was not equal expected' ); expect( - file(testUtils.getActualFile('testExisting_script_mixed', 'script', 'html')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'script', 'get_mixed', 'html'))); - expect(file(testUtils.getActualFile('testExisting_script_mixed', 'script', 'ssjs'))).to + await testUtils.getActualFile('testExisting_script_mixed', 'script', 'html') + ).to.equal(await testUtils.getExpectedFile('9999999', 'script', 'get_mixed', 'html')); + expect(await testUtils.getActualFile('testExisting_script_mixed', 'script', 'ssjs')).to .not.exist; assert.equal( @@ -133,20 +132,20 @@ describe('type: script', () => { await testUtils.getExpectedJson('9999999', 'script', 'get'), 'returned metadata was not equal expected' ); - expect(file(testUtils.getActualFile('testExisting_script', 'script', 'html'))).to.not + expect(await testUtils.getActualFile('testExisting_script', 'script', 'html')).to.not .exist; - expect(file(testUtils.getActualFile('testExisting_script', 'script', 'ssjs'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'script', 'get', 'ssjs')) + expect(await testUtils.getActualFile('testExisting_script', 'script', 'ssjs')).to.equal( + await testUtils.getExpectedFile('9999999', 'script', 'get', 'ssjs') ); expect( - file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'json')) + await testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'json') ).to.not.exist; expect( - file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'ssjs')) + await testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'ssjs') ).to.not.exist; expect( - file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'html')) + await testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'html') ).to.not.exist; assert.equal( @@ -177,18 +176,18 @@ describe('type: script', () => { await testUtils.getExpectedJson('9999999', 'script', 'get'), 'returned metadata was not equal expected' ); - expect(file(testUtils.getActualFile('testExisting_script', 'script', 'ssjs'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'script', 'get', 'ssjs')) + expect(await testUtils.getActualFile('testExisting_script', 'script', 'ssjs')).to.equal( + await testUtils.getExpectedFile('9999999', 'script', 'get', 'ssjs') ); expect( - file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'json')) + await testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'json') ).to.not.exist; expect( - file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'ssjs')) + await testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'ssjs') ).to.not.exist; expect( - file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'html')) + await testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'html') ).to.not.exist; assert.equal( @@ -214,7 +213,7 @@ describe('type: script', () => { '5 scripts in cache expected' ); - expect(file(testUtils.getActualFile('testExisting_script', 'script', 'ssjs'))).to.not + expect(await testUtils.getActualFile('testExisting_script', 'script', 'ssjs')).to.not .exist; assert.equal( testUtils.getAPIHistoryLength(), @@ -254,10 +253,10 @@ describe('type: script', () => { await testUtils.getExpectedJson('9999999', 'script', 'patch'), 'returned metadata was not equal expected for insert script' ); - expect(file(testUtils.getActualFile('testExisting_script', 'script', 'html'))).to.not + expect(await testUtils.getActualFile('testExisting_script', 'script', 'html')).to.not .exist; - expect(file(testUtils.getActualFile('testExisting_script', 'script', 'ssjs'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'script', 'patch', 'ssjs')) + expect(await testUtils.getActualFile('testExisting_script', 'script', 'ssjs')).to.equal( + await testUtils.getExpectedFile('9999999', 'script', 'patch', 'ssjs') ); // check number of API calls assert.equal( @@ -291,8 +290,8 @@ describe('type: script', () => { 'returned template JSON of retrieveAsTemplate was not equal expected' ); expect( - file(testUtils.getActualTemplateFile('testExisting_script', 'script', 'ssjs')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'script', 'template', 'ssjs'))); + await testUtils.getActualTemplateFile('testExisting_script', 'script', 'ssjs') + ).to.equal(await testUtils.getExpectedFile('9999999', 'script', 'template', 'ssjs')); // THEN await handler.buildDefinition( 'testInstance/testBU', @@ -308,8 +307,8 @@ describe('type: script', () => { 'returned deployment JSON was not equal expected' ); expect( - file(testUtils.getActualDeployFile('testTemplated_script', 'script', 'ssjs')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'script', 'build', 'ssjs'))); + await testUtils.getActualDeployFile('testTemplated_script', 'script', 'ssjs') + ).to.equal(await testUtils.getExpectedFile('9999999', 'script', 'build', 'ssjs')); assert.equal( testUtils.getAPIHistoryLength(), @@ -343,8 +342,8 @@ describe('type: script', () => { 'returned template JSON of buildTemplate was not equal expected' ); expect( - file(testUtils.getActualTemplateFile('testExisting_script', 'script', 'ssjs')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'script', 'template', 'ssjs'))); + await testUtils.getActualTemplateFile('testExisting_script', 'script', 'ssjs') + ).to.equal(await testUtils.getExpectedFile('9999999', 'script', 'template', 'ssjs')); // THEN await handler.buildDefinition( 'testInstance/testBU', @@ -360,8 +359,8 @@ describe('type: script', () => { 'returned deployment JSON was not equal expected' ); expect( - file(testUtils.getActualDeployFile('testTemplated_script', 'script', 'ssjs')) - ).to.equal(file(testUtils.getExpectedFile('9999999', 'script', 'build', 'ssjs'))); + await testUtils.getActualDeployFile('testTemplated_script', 'script', 'ssjs') + ).to.equal(await testUtils.getExpectedFile('9999999', 'script', 'build', 'ssjs')); assert.equal( testUtils.getAPIHistoryLength(), diff --git a/test/type.transactionalSMS.test.js b/test/type.transactionalSMS.test.js index 8915390a5..4c531d275 100644 --- a/test/type.transactionalSMS.test.js +++ b/test/type.transactionalSMS.test.js @@ -7,7 +7,6 @@ import cache from '../lib/util/cache.js'; import * as testUtils from './utils.js'; import handler from '../lib/index.js'; chai.use(chaiFiles); -const file = chaiFiles.file; describe('type: transactionalSMS', () => { beforeEach(() => { @@ -37,9 +36,9 @@ describe('type: transactionalSMS', () => { 'returned JSON was not equal expected' ); expect( - file(testUtils.getActualFile('testExisting_tsms', 'transactionalSMS', 'amp')) + await testUtils.getActualFile('testExisting_tsms', 'transactionalSMS', 'amp') ).to.equal( - file(testUtils.getExpectedFile('9999999', 'transactionalSMS', 'get', 'amp')) + await testUtils.getExpectedFile('9999999', 'transactionalSMS', 'get', 'amp') ); assert.equal( testUtils.getAPIHistoryLength(), @@ -74,9 +73,9 @@ describe('type: transactionalSMS', () => { 'returned JSON was not equal expected for insert transactionalSMS' ); expect( - file(testUtils.getActualFile('testNew_tsms', 'transactionalSMS', 'amp')) + await testUtils.getActualFile('testNew_tsms', 'transactionalSMS', 'amp') ).to.equal( - file(testUtils.getExpectedFile('9999999', 'transactionalSMS', 'post', 'amp')) + await testUtils.getExpectedFile('9999999', 'transactionalSMS', 'post', 'amp') ); // confirm updated item assert.deepEqual( @@ -85,9 +84,9 @@ describe('type: transactionalSMS', () => { 'returned JSON was not equal expected for update transactionalSMS' ); expect( - file(testUtils.getActualFile('testExisting_tsms', 'transactionalSMS', 'amp')) + await testUtils.getActualFile('testExisting_tsms', 'transactionalSMS', 'amp') ).to.equal( - file(testUtils.getExpectedFile('9999999', 'transactionalSMS', 'patch', 'amp')) + await testUtils.getExpectedFile('9999999', 'transactionalSMS', 'patch', 'amp') ); // check number of API calls assert.equal( @@ -141,11 +140,13 @@ describe('type: transactionalSMS', () => { 'returned template JSON was not equal expected' ); expect( - file( - testUtils.getActualTemplateFile('testExisting_tsms', 'transactionalSMS', 'amp') + await testUtils.getActualTemplateFile( + 'testExisting_tsms', + 'transactionalSMS', + 'amp' ) ).to.equal( - file(testUtils.getExpectedFile('9999999', 'transactionalSMS', 'template', 'amp')) + await testUtils.getExpectedFile('9999999', 'transactionalSMS', 'template', 'amp') ); // buildDefinition await handler.buildDefinition( @@ -162,9 +163,9 @@ describe('type: transactionalSMS', () => { 'returned deployment JSON was not equal expected' ); expect( - file(testUtils.getActualDeployFile('testTemplated_tsms', 'transactionalSMS', 'amp')) + await testUtils.getActualDeployFile('testTemplated_tsms', 'transactionalSMS', 'amp') ).to.equal( - file(testUtils.getExpectedFile('9999999', 'transactionalSMS', 'build', 'amp')) + await testUtils.getExpectedFile('9999999', 'transactionalSMS', 'build', 'amp') ); assert.equal( testUtils.getAPIHistoryLength(), diff --git a/test/type.user.test.js b/test/type.user.test.js index 16100fe2f..784a58dad 100644 --- a/test/type.user.test.js +++ b/test/type.user.test.js @@ -40,9 +40,11 @@ describe('type: user', () => { ); // check if MD file was created and equals expectations // ! this test needs to update the lastLoginDate counter because it changes with every passing day - const expectedFile = await File.readFile( - testUtils.getExpectedFile('1111111', 'user', 'retrieve', 'md'), - { encoding: 'utf8' } + const expectedFile = await testUtils.getExpectedFile( + '1111111', + 'user', + 'retrieve', + 'md' ); const regexFindDaysSinceLogin = /\| (\d*) (seconds|minutes|days|weeks|months|years){1} \|/g; diff --git a/test/utils.js b/test/utils.js index 4050ac479..33bf1ab60 100644 --- a/test/utils.js +++ b/test/utils.js @@ -36,10 +36,13 @@ export function getActualJson(customerKey, type, buName = 'testBU') { * @param {string} customerKey of metadata * @param {string} type of metadata * @param {string} [buName] used when we need to test on ParentBU - * @returns {string} file path + * @returns {Promise.} file path */ export function getActualDoc(customerKey, type, buName = 'testBU') { - return `./retrieve/testInstance/${buName}/${type}/${customerKey}.${type}-doc.md`; + return File.readFile( + `./retrieve/testInstance/${buName}/${type}/${customerKey}.${type}-doc.md`, + 'utf8' + ); } /** * gets file from Retrieve folder @@ -48,10 +51,13 @@ export function getActualDoc(customerKey, type, buName = 'testBU') { * @param {string} type of metadata * @param {string} ext file extension * @param {string} [buName] used when we need to test on ParentBU - * @returns {string} file path + * @returns {Promise.} file in string form */ export function getActualFile(customerKey, type, ext, buName = 'testBU') { - return `./retrieve/testInstance/${buName}/${type}/${customerKey}.${type}-meta.${ext}`; + return File.readFile( + `./retrieve/testInstance/${buName}/${type}/${customerKey}.${type}-meta.${ext}`, + 'utf8' + ); } /** * gets file from Deploy folder @@ -59,7 +65,7 @@ export function getActualFile(customerKey, type, ext, buName = 'testBU') { * @param {string} customerKey of metadata * @param {string} type of metadata * @param {string} [buName] used when we need to test on ParentBU - * @returns {Promise.} file in string form + * @returns {Promise.} file in JSON form */ export function getActualDeployJson(customerKey, type, buName = 'testBU') { return File.readJSON( @@ -73,17 +79,20 @@ export function getActualDeployJson(customerKey, type, buName = 'testBU') { * @param {string} type of metadata * @param {string} ext file extension * @param {string} [buName] used when we need to test on ParentBU - * @returns {string} file path + * @returns {Promise.} file in string form */ export function getActualDeployFile(customerKey, type, ext, buName = 'testBU') { - return `./deploy/testInstance/${buName}/${type}/${customerKey}.${type}-meta.${ext}`; + return File.readFile( + `./deploy/testInstance/${buName}/${type}/${customerKey}.${type}-meta.${ext}`, + 'utf8' + ); } /** * gets file from Template folder * * @param {string} customerKey of metadata * @param {string} type of metadata - * @returns {Promise.} file in string form + * @returns {Promise.} file in JSON form */ export function getActualTemplateJson(customerKey, type) { return File.readJSON(`./template/${type}/${customerKey}.${type}-meta.json`); @@ -94,10 +103,10 @@ export function getActualTemplateJson(customerKey, type) { * @param {string} customerKey of metadata * @param {string} type of metadata * @param {string} ext file extension - * @returns {string} file path + * @returns {Promise.} file in string form */ export function getActualTemplateFile(customerKey, type, ext) { - return `./template/${type}/${customerKey}.${type}-meta.${ext}`; + return File.readFile(`./template/${type}/${customerKey}.${type}-meta.${ext}`, 'utf8'); } /** * gets file from resources folder which should be used for comparison @@ -105,10 +114,10 @@ export function getActualTemplateFile(customerKey, type, ext) { * @param {string} mid of Business Unit * @param {string} type of metadata * @param {string} action of SOAP request - * @returns {Promise.} file in string form + * @returns {Promise.} file in JSON form */ export function getExpectedJson(mid, type, action) { - return File.readJSON(path.join('test', 'resources', mid, type, action + '-expected.json')); + return File.readJSON(`./test/resources/${mid}/${type}/${action}-expected.json`); } /** * gets file from resources folder which should be used for comparison @@ -117,10 +126,10 @@ export function getExpectedJson(mid, type, action) { * @param {string} type of metadata * @param {string} action of SOAP request * @param {string} ext file extension - * @returns {string} file path + * @returns {Promise.} file in string form */ export function getExpectedFile(mid, type, action, ext) { - return path.join('test', 'resources', mid, type, action + '-expected.' + ext); + return File.readFile(`./test/resources/${mid}/${type}/${action}-expected.${ext}`, 'utf8'); } /** * setup mocks for API and FS