mcdev 4.1.12 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/.eslintrc.json +1 -1
  2. package/.github/ISSUE_TEMPLATE/bug.yml +1 -0
  3. package/.github/PULL_REQUEST_TEMPLATE.md +2 -3
  4. package/.nycrc.json +5 -0
  5. package/README.md +34 -1528
  6. package/boilerplate/config.json +2 -6
  7. package/boilerplate/files/.vscode/extensions.json +1 -0
  8. package/boilerplate/files/.vscode/settings.json +3 -0
  9. package/docs/dist/documentation.md +437 -31
  10. package/lib/Deployer.js +10 -8
  11. package/lib/MetadataTypeDefinitions.js +3 -0
  12. package/lib/MetadataTypeInfo.js +3 -0
  13. package/lib/Retriever.js +14 -7
  14. package/lib/cli.js +1 -0
  15. package/lib/index.js +6 -6
  16. package/lib/metadataTypes/AccountUser.js +2 -2
  17. package/lib/metadataTypes/Asset.js +45 -35
  18. package/lib/metadataTypes/Automation.js +4 -4
  19. package/lib/metadataTypes/DataExtension.js +14 -8
  20. package/lib/metadataTypes/DataExtensionField.js +44 -9
  21. package/lib/metadataTypes/Discovery.js +5 -5
  22. package/lib/metadataTypes/Folder.js +30 -6
  23. package/lib/metadataTypes/List.js +115 -17
  24. package/lib/metadataTypes/MetadataType.js +73 -40
  25. package/lib/metadataTypes/Query.js +2 -2
  26. package/lib/metadataTypes/Script.js +2 -2
  27. package/lib/metadataTypes/TransactionalEmail.js +163 -0
  28. package/lib/metadataTypes/TransactionalMessage.js +127 -0
  29. package/lib/metadataTypes/TransactionalPush.js +77 -0
  30. package/lib/metadataTypes/TransactionalSMS.js +354 -0
  31. package/lib/metadataTypes/TriggeredSendDefinition.js +11 -9
  32. package/lib/metadataTypes/definitions/TransactionalEmail.definition.js +145 -0
  33. package/lib/metadataTypes/definitions/TransactionalPush.definition.js +109 -0
  34. package/lib/metadataTypes/definitions/TransactionalSMS.definition.js +103 -0
  35. package/lib/metadataTypes/definitions/TriggeredSendDefinition.definition.js +36 -36
  36. package/lib/util/auth.js +2 -2
  37. package/lib/util/businessUnit.js +1 -1
  38. package/lib/util/cli.js +19 -20
  39. package/lib/util/config.js +13 -12
  40. package/lib/util/devops.js +4 -4
  41. package/lib/util/init.config.js +7 -7
  42. package/lib/util/init.git.js +11 -23
  43. package/lib/util/init.js +67 -3
  44. package/lib/util/util.js +20 -12
  45. package/package.json +19 -12
  46. package/test/dataExtension.test.js +36 -19
  47. package/test/mockRoot/.mcdevrc.json +13 -2
  48. package/test/mockRoot/deploy/testInstance/testBU/dataExtension/childBU_dataextension_test.dataExtension-meta.json +27 -7
  49. package/test/mockRoot/deploy/testInstance/testBU/query/testExistingQuery.query-meta.json +1 -1
  50. package/test/mockRoot/deploy/testInstance/testBU/query/testExistingQuery.query-meta.sql +3 -1
  51. package/test/mockRoot/deploy/testInstance/testBU/query/{testQuery.query-meta.json → testNewQuery.query-meta.json} +3 -3
  52. package/test/mockRoot/deploy/testInstance/testBU/query/{testQuery.query-meta.sql → testNewQuery.query-meta.sql} +0 -0
  53. package/test/mockRoot/deploy/testInstance/testBU/transactionalEmail/testExisting_temail.transactionalEmail-meta.json +24 -0
  54. package/test/mockRoot/deploy/testInstance/testBU/transactionalEmail/testNew_temail.transactionalEmail-meta.json +24 -0
  55. package/test/mockRoot/deploy/testInstance/testBU/transactionalPush/testExisting_tpush.transactionalPush-meta.json +18 -0
  56. package/test/mockRoot/deploy/testInstance/testBU/transactionalPush/testNew_tpush.transactionalPush-meta.json +18 -0
  57. package/test/mockRoot/deploy/testInstance/testBU/transactionalSMS/testExisting_tsms.transactionalSMS-meta.amp +4 -0
  58. package/test/mockRoot/deploy/testInstance/testBU/transactionalSMS/testExisting_tsms.transactionalSMS-meta.json +15 -0
  59. package/test/mockRoot/deploy/testInstance/testBU/transactionalSMS/testNew_tsms.transactionalSMS-meta.amp +4 -0
  60. package/test/mockRoot/deploy/testInstance/testBU/transactionalSMS/testNew_tsms.transactionalSMS-meta.json +15 -0
  61. package/test/query.test.js +57 -23
  62. package/test/resources/1111111/businessUnit/retrieve-response.xml +33 -0
  63. package/test/resources/1111111/list/retrieve-response.xml +39 -0
  64. package/test/resources/9999999/asset/v1/content/assets/query/post-response.json +72 -0
  65. package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/patch-response.json +2 -2
  66. package/test/resources/9999999/automation/v1/queries/get-response.json +2 -2
  67. package/test/resources/9999999/automation/v1/queries/post-response.json +3 -3
  68. package/test/resources/9999999/dataExtension/build-expected.json +2 -2
  69. package/test/resources/9999999/dataFolder/retrieve-response.xml +95 -2
  70. package/test/resources/9999999/interaction/v1/interactions/get-response.json +296 -0
  71. package/test/resources/9999999/legacy/v1/beta/mobile/code/get-response.json +32 -0
  72. package/test/resources/9999999/legacy/v1/beta/mobile/keyword/get-response.json +46 -0
  73. package/test/resources/9999999/list/retrieve-response.xml +78 -0
  74. package/test/resources/9999999/messaging/v1/email/definitions/get-response.json +15 -0
  75. package/test/resources/9999999/messaging/v1/email/definitions/post-response.json +19 -0
  76. package/test/resources/9999999/messaging/v1/email/definitions/testExisting_temail/get-response.json +26 -0
  77. package/test/resources/9999999/messaging/v1/email/definitions/testExisting_temail/patch-response.json +26 -0
  78. package/test/resources/9999999/messaging/v1/push/definitions/get-response.json +15 -0
  79. package/test/resources/9999999/messaging/v1/push/definitions/post-response.json +13 -0
  80. package/test/resources/9999999/messaging/v1/push/definitions/testExisting_tpush/get-response.json +13 -0
  81. package/test/resources/9999999/messaging/v1/push/definitions/testExisting_tpush/patch-response.json +13 -0
  82. package/test/resources/9999999/messaging/v1/sms/definitions/get-response.json +15 -0
  83. package/test/resources/9999999/messaging/v1/sms/definitions/post-response.json +17 -0
  84. package/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/get-response.json +18 -0
  85. package/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/patch-response.json +18 -0
  86. package/test/resources/9999999/query/build-expected.json +2 -2
  87. package/test/resources/9999999/query/build-expected.sql +6 -0
  88. package/test/resources/9999999/query/get-expected.json +1 -1
  89. package/test/resources/9999999/query/get-expected.sql +6 -0
  90. package/test/resources/9999999/query/patch-expected.json +1 -1
  91. package/test/resources/9999999/query/patch-expected.sql +6 -0
  92. package/test/resources/9999999/query/post-expected.json +3 -3
  93. package/test/resources/9999999/query/post-expected.sql +4 -0
  94. package/test/resources/9999999/query/template-expected.json +1 -1
  95. package/test/resources/9999999/query/template-expected.sql +6 -0
  96. package/test/resources/9999999/transactionalEmail/build-expected.json +22 -0
  97. package/test/resources/9999999/transactionalEmail/get-expected.json +24 -0
  98. package/test/resources/9999999/transactionalEmail/patch-expected.json +24 -0
  99. package/test/resources/9999999/transactionalEmail/post-expected.json +24 -0
  100. package/test/resources/9999999/transactionalEmail/template-expected.json +22 -0
  101. package/test/resources/9999999/transactionalPush/build-expected.json +8 -0
  102. package/test/resources/9999999/transactionalPush/get-expected.json +11 -0
  103. package/test/resources/9999999/transactionalPush/patch-expected.json +16 -0
  104. package/test/resources/9999999/transactionalPush/post-expected.json +16 -0
  105. package/test/resources/9999999/transactionalPush/template-expected.json +8 -0
  106. package/test/resources/9999999/transactionalSMS/build-expected.amp +4 -0
  107. package/test/resources/9999999/transactionalSMS/build-expected.json +13 -0
  108. package/test/resources/9999999/transactionalSMS/get-expected.amp +4 -0
  109. package/test/resources/9999999/transactionalSMS/get-expected.json +15 -0
  110. package/test/resources/9999999/transactionalSMS/patch-expected.amp +4 -0
  111. package/test/resources/9999999/transactionalSMS/patch-expected.json +15 -0
  112. package/test/resources/9999999/transactionalSMS/post-expected.amp +4 -0
  113. package/test/resources/9999999/transactionalSMS/post-expected.json +15 -0
  114. package/test/resources/9999999/transactionalSMS/template-expected.amp +4 -0
  115. package/test/resources/9999999/transactionalSMS/template-expected.json +13 -0
  116. package/test/transactionalEmail.test.js +120 -0
  117. package/test/transactionalPush.test.js +120 -0
  118. package/test/transactionalSMS.test.js +149 -0
  119. package/test/utils.js +57 -8
@@ -0,0 +1,120 @@
1
+ const chai = require('chai');
2
+ const chaiFiles = require('chai-files');
3
+ const assert = chai.assert;
4
+ chai.use(chaiFiles);
5
+ const cache = require('../lib/util/cache');
6
+ const testUtils = require('./utils');
7
+ const handler = require('../lib/index');
8
+
9
+ describe('transactionalPush', () => {
10
+ beforeEach(() => {
11
+ testUtils.mockSetup();
12
+ });
13
+ afterEach(() => {
14
+ testUtils.mockReset();
15
+ });
16
+
17
+ describe('Retrieve ================', () => {
18
+ it('Should retrieve a transactionalPush', async () => {
19
+ // WHEN
20
+ await handler.retrieve('testInstance/testBU', ['transactionalPush']);
21
+ // THEN
22
+ // get results from cache
23
+ const result = cache.getCache();
24
+ assert.equal(
25
+ result.transactionalPush ? Object.keys(result.transactionalPush).length : 0,
26
+ 1,
27
+ 'only one transactionalPush expected'
28
+ );
29
+ assert.deepEqual(
30
+ await testUtils.getActualJson('testExisting_tpush', 'transactionalPush'),
31
+ await testUtils.getExpectedJson('9999999', 'transactionalPush', 'get'),
32
+ 'returned JSON was not equal expected'
33
+ );
34
+ assert.equal(
35
+ Object.values(testUtils.getAPIHistory()).flat().length,
36
+ 3,
37
+ 'Unexpected number of requests made'
38
+ );
39
+ return;
40
+ });
41
+ });
42
+ describe('Deploy ================', () => {
43
+ beforeEach(() => {
44
+ testUtils.mockSetup(true);
45
+ });
46
+ it('Should create & upsert a transactionalPush', async () => {
47
+ // WHEN
48
+ await handler.deploy('testInstance/testBU', ['transactionalPush']);
49
+ // THEN
50
+ // get results from cache
51
+ const result = cache.getCache();
52
+ assert.equal(
53
+ result.transactionalPush ? Object.keys(result.transactionalPush).length : 0,
54
+ 2,
55
+ 'two transactionalPushs expected'
56
+ );
57
+ // confirm created item
58
+ assert.deepEqual(
59
+ await testUtils.getActualJson('testNew_tpush', 'transactionalPush'),
60
+ await testUtils.getExpectedJson('9999999', 'transactionalPush', 'post'),
61
+ 'returned JSON was not equal expected for insert transactionalPush'
62
+ );
63
+ // confirm updated item
64
+ assert.deepEqual(
65
+ await testUtils.getActualJson('testExisting_tpush', 'transactionalPush'),
66
+ await testUtils.getExpectedJson('9999999', 'transactionalPush', 'patch'),
67
+ 'returned JSON was not equal expected for update transactionalPush'
68
+ );
69
+ // check number of API calls
70
+ assert.equal(
71
+ Object.values(testUtils.getAPIHistory()).flat().length,
72
+ 4,
73
+ 'Unexpected number of requests made'
74
+ );
75
+ return;
76
+ });
77
+ });
78
+ describe('Templating ================', () => {
79
+ // it.skip('Should create a transactionalPush template via retrieveAsTemplate and build it');
80
+ it('Should create a transactionalPush template via buildTemplate and build it', async () => {
81
+ // download first before we test buildTemplate
82
+ await handler.retrieve('testInstance/testBU', ['transactionalPush']);
83
+ // buildTemplate
84
+ const result = await handler.buildTemplate(
85
+ 'testInstance/testBU',
86
+ 'transactionalPush',
87
+ ['testExisting_tpush'],
88
+ 'testSourceMarket'
89
+ );
90
+ assert.equal(
91
+ result.transactionalPush ? Object.keys(result.transactionalPush).length : 0,
92
+ 1,
93
+ 'only one transactionalPush expected'
94
+ );
95
+ assert.deepEqual(
96
+ await testUtils.getActualTemplateJson('testExisting_tpush', 'transactionalPush'),
97
+ await testUtils.getExpectedJson('9999999', 'transactionalPush', 'template'),
98
+ 'returned template JSON was not equal expected'
99
+ );
100
+ // buildDefinition
101
+ await handler.buildDefinition(
102
+ 'testInstance/testBU',
103
+ 'transactionalPush',
104
+ 'testExisting_tpush',
105
+ 'testTargetMarket'
106
+ );
107
+ assert.deepEqual(
108
+ await testUtils.getActualDeployJson('testExisting_tpush', 'transactionalPush'),
109
+ await testUtils.getExpectedJson('9999999', 'transactionalPush', 'build'),
110
+ 'returned deployment JSON was not equal expected'
111
+ );
112
+ assert.equal(
113
+ Object.values(testUtils.getAPIHistory()).flat().length,
114
+ 3,
115
+ 'Unexpected number of requests made'
116
+ );
117
+ return;
118
+ });
119
+ });
120
+ });
@@ -0,0 +1,149 @@
1
+ const chai = require('chai');
2
+ const chaiFiles = require('chai-files');
3
+ const assert = chai.assert;
4
+ chai.use(chaiFiles);
5
+ const expect = chai.expect;
6
+ const file = chaiFiles.file;
7
+ const cache = require('../lib/util/cache');
8
+ const testUtils = require('./utils');
9
+ const handler = require('../lib/index');
10
+
11
+ describe('transactionalSMS', () => {
12
+ beforeEach(() => {
13
+ testUtils.mockSetup();
14
+ });
15
+ afterEach(() => {
16
+ testUtils.mockReset();
17
+ });
18
+
19
+ describe('Retrieve ================', () => {
20
+ it('Should retrieve a transactionalSMS', async () => {
21
+ // WHEN
22
+ await handler.retrieve('testInstance/testBU', ['transactionalSMS']);
23
+ // THEN
24
+ // get results from cache
25
+ const result = cache.getCache();
26
+ assert.equal(
27
+ result.transactionalSMS ? Object.keys(result.transactionalSMS).length : 0,
28
+ 1,
29
+ 'only one transactionalSMS expected'
30
+ );
31
+ assert.deepEqual(
32
+ await testUtils.getActualJson('testExisting_tsms', 'transactionalSMS'),
33
+ await testUtils.getExpectedJson('9999999', 'transactionalSMS', 'get'),
34
+ 'returned JSON was not equal expected'
35
+ );
36
+ expect(
37
+ file(testUtils.getActualFile('testExisting_tsms', 'transactionalSMS', 'amp'))
38
+ ).to.equal(
39
+ file(testUtils.getExpectedFile('9999999', 'transactionalSMS', 'get', 'amp'))
40
+ );
41
+ assert.equal(
42
+ Object.values(testUtils.getAPIHistory()).flat().length,
43
+ 4,
44
+ 'Unexpected number of requests made'
45
+ );
46
+ return;
47
+ });
48
+ });
49
+ describe('Deploy ================', () => {
50
+ beforeEach(() => {
51
+ testUtils.mockSetup(true);
52
+ });
53
+ it('Should create & upsert a transactionalSMS', async () => {
54
+ // WHEN
55
+ await handler.deploy('testInstance/testBU', ['transactionalSMS']);
56
+ // THEN
57
+ // get results from cache
58
+ const result = cache.getCache();
59
+ assert.equal(
60
+ result.transactionalSMS ? Object.keys(result.transactionalSMS).length : 0,
61
+ 2,
62
+ 'two transactionalSMSs expected'
63
+ );
64
+ // confirm created item
65
+ assert.deepEqual(
66
+ await testUtils.getActualJson('testNew_tsms', 'transactionalSMS'),
67
+ await testUtils.getExpectedJson('9999999', 'transactionalSMS', 'post'),
68
+ 'returned JSON was not equal expected for insert transactionalSMS'
69
+ );
70
+ expect(
71
+ file(testUtils.getActualFile('testNew_tsms', 'transactionalSMS', 'amp'))
72
+ ).to.equal(
73
+ file(testUtils.getExpectedFile('9999999', 'transactionalSMS', 'post', 'amp'))
74
+ );
75
+ // confirm updated item
76
+ assert.deepEqual(
77
+ await testUtils.getActualJson('testExisting_tsms', 'transactionalSMS'),
78
+ await testUtils.getExpectedJson('9999999', 'transactionalSMS', 'patch'),
79
+ 'returned JSON was not equal expected for update transactionalSMS'
80
+ );
81
+ expect(
82
+ file(testUtils.getActualFile('testExisting_tsms', 'transactionalSMS', 'amp'))
83
+ ).to.equal(
84
+ file(testUtils.getExpectedFile('9999999', 'transactionalSMS', 'patch', 'amp'))
85
+ );
86
+ // check number of API calls
87
+ assert.equal(
88
+ Object.values(testUtils.getAPIHistory()).flat().length,
89
+ 5,
90
+ 'Unexpected number of requests made'
91
+ );
92
+ return;
93
+ });
94
+ });
95
+ describe('Templating ================', () => {
96
+ // it.skip('Should create a transactionalSMS template via retrieveAsTemplate and build it');
97
+ it('Should create a transactionalSMS template via buildTemplate and build it', async () => {
98
+ // download first before we test buildTemplate
99
+ await handler.retrieve('testInstance/testBU', ['transactionalSMS']);
100
+ // buildTemplate
101
+ const result = await handler.buildTemplate(
102
+ 'testInstance/testBU',
103
+ 'transactionalSMS',
104
+ ['testExisting_tsms'],
105
+ 'testSourceMarket'
106
+ );
107
+ assert.equal(
108
+ result.transactionalSMS ? Object.keys(result.transactionalSMS).length : 0,
109
+ 1,
110
+ 'only one transactionalSMS expected'
111
+ );
112
+ assert.deepEqual(
113
+ await testUtils.getActualTemplateJson('testExisting_tsms', 'transactionalSMS'),
114
+ await testUtils.getExpectedJson('9999999', 'transactionalSMS', 'template'),
115
+ 'returned template JSON was not equal expected'
116
+ );
117
+ expect(
118
+ file(
119
+ testUtils.getActualTemplateFile('testExisting_tsms', 'transactionalSMS', 'amp')
120
+ )
121
+ ).to.equal(
122
+ file(testUtils.getExpectedFile('9999999', 'transactionalSMS', 'template', 'amp'))
123
+ );
124
+ // buildDefinition
125
+ await handler.buildDefinition(
126
+ 'testInstance/testBU',
127
+ 'transactionalSMS',
128
+ 'testExisting_tsms',
129
+ 'testTargetMarket'
130
+ );
131
+ assert.deepEqual(
132
+ await testUtils.getActualDeployJson('testExisting_tsms', 'transactionalSMS'),
133
+ await testUtils.getExpectedJson('9999999', 'transactionalSMS', 'build'),
134
+ 'returned deployment JSON was not equal expected'
135
+ );
136
+ expect(
137
+ file(testUtils.getActualDeployFile('testExisting_tsms', 'transactionalSMS', 'amp'))
138
+ ).to.equal(
139
+ file(testUtils.getExpectedFile('9999999', 'transactionalSMS', 'build', 'amp'))
140
+ );
141
+ assert.equal(
142
+ Object.values(testUtils.getAPIHistory()).flat().length,
143
+ 4,
144
+ 'Unexpected number of requests made'
145
+ );
146
+ return;
147
+ });
148
+ });
149
+ });
package/test/utils.js CHANGED
@@ -19,8 +19,18 @@ const resourceFactory = require('./resourceFactory');
19
19
  * @param {string} type of metadata
20
20
  * @returns {Promise.<string>} file in string form
21
21
  */
22
- exports.getActualFile = (customerKey, type) =>
22
+ exports.getActualJson = (customerKey, type) =>
23
23
  File.readJSON(`./retrieve/testInstance/testBU/${type}/${customerKey}.${type}-meta.json`);
24
+ /**
25
+ * gets file from Retrieve folder
26
+ *
27
+ * @param {string} customerKey of metadata
28
+ * @param {string} type of metadata
29
+ * @param {string} ext file extension
30
+ * @returns {Promise.<string>} file in string form
31
+ */
32
+ exports.getActualFile = (customerKey, type, ext) =>
33
+ `./retrieve/testInstance/testBU/${type}/${customerKey}.${type}-meta.${ext}`;
24
34
  /**
25
35
  * gets file from Deploy folder
26
36
  *
@@ -28,8 +38,18 @@ exports.getActualFile = (customerKey, type) =>
28
38
  * @param {string} type of metadata
29
39
  * @returns {Promise.<string>} file in string form
30
40
  */
31
- exports.getActualDeployFile = (customerKey, type) =>
41
+ exports.getActualDeployJson = (customerKey, type) =>
32
42
  File.readJSON(`./deploy/testInstance/testBU/${type}/${customerKey}.${type}-meta.json`);
43
+ /**
44
+ * gets file from Deploy folder
45
+ *
46
+ * @param {string} customerKey of metadata
47
+ * @param {string} type of metadata
48
+ * @param {string} ext file extension
49
+ * @returns {Promise.<string>} file in string form
50
+ */
51
+ exports.getActualDeployFile = (customerKey, type, ext) =>
52
+ `./deploy/testInstance/testBU/${type}/${customerKey}.${type}-meta.${ext}`;
33
53
  /**
34
54
  * gets file from Template folder
35
55
  *
@@ -37,8 +57,18 @@ exports.getActualDeployFile = (customerKey, type) =>
37
57
  * @param {string} type of metadata
38
58
  * @returns {Promise.<string>} file in string form
39
59
  */
40
- exports.getActualTemplate = (customerKey, type) =>
60
+ exports.getActualTemplateJson = (customerKey, type) =>
41
61
  File.readJSON(`./template/${type}/${customerKey}.${type}-meta.json`);
62
+ /**
63
+ * gets file from Template folder
64
+ *
65
+ * @param {string} customerKey of metadata
66
+ * @param {string} type of metadata
67
+ * @param {string} ext file extension
68
+ * @returns {Promise.<string>} file in string form
69
+ */
70
+ exports.getActualTemplateFile = (customerKey, type, ext) =>
71
+ `./template/${type}/${customerKey}.${type}-meta.${ext}`;
42
72
 
43
73
  /**
44
74
  * gets file from resources folder which should be used for comparison
@@ -48,14 +78,27 @@ exports.getActualTemplate = (customerKey, type) =>
48
78
  * @param {string} action of SOAP request
49
79
  * @returns {Promise.<string>} file in string form
50
80
  */
51
- exports.getExpectedFile = (mid, type, action) =>
81
+ exports.getExpectedJson = (mid, type, action) =>
52
82
  File.readJSON(path.join('test', 'resources', mid, type, action + '-expected.json'));
83
+ /**
84
+ * gets file from resources folder which should be used for comparison
85
+ *
86
+ * @param {number} mid of Business Unit
87
+ * @param {string} type of metadata
88
+ * @param {string} action of SOAP request
89
+ * @param {string} ext file extension
90
+ * @returns {Promise.<string>} file in string form
91
+ */
92
+ exports.getExpectedFile = (mid, type, action, ext) =>
93
+ path.join('test', 'resources', mid, type, action + '-expected.' + ext);
53
94
  /**
54
95
  * setup mocks for API and FS
55
96
  *
97
+ * @param {boolean} [isDeploy] if true, will mock deploy folder
56
98
  * @returns {void}
57
99
  */
58
- exports.mockSetup = () => {
100
+
101
+ exports.mockSetup = (isDeploy) => {
59
102
  Util.setLoggingLevel({ debug: true });
60
103
  apimock = new MockAdapter(axios, { onNoMatch: 'throwException' });
61
104
  // set access_token to mid to allow for autorouting of mock to correct resources
@@ -69,17 +112,22 @@ exports.mockSetup = () => {
69
112
  apimock
70
113
  .onAny(new RegExp(`^${escapeRegExp(resourceFactory.restUrl)}`))
71
114
  .reply((config) => resourceFactory.handleRESTRequest(config));
72
- fsmock({
115
+ const fsMockConf = {
73
116
  '.prettierrc': fsmock.load(path.resolve(__dirname, '../boilerplate/files/.prettierrc')),
74
117
  '.mcdevrc.json': fsmock.load(path.resolve(__dirname, 'mockRoot/.mcdevrc.json')),
75
118
  '.mcdev-auth.json': fsmock.load(path.resolve(__dirname, 'mockRoot/.mcdev-auth.json')),
76
119
  'boilerplate/config.json': fsmock.load(
77
120
  path.resolve(__dirname, '../boilerplate/config.json')
78
121
  ),
79
- deploy: fsmock.load(path.resolve(__dirname, 'mockRoot/deploy')),
80
122
  test: fsmock.load(path.resolve(__dirname)),
81
- });
123
+ };
124
+ if (isDeploy) {
125
+ // load files we manually prepared for a direct test of `deploy` command
126
+ fsMockConf.deploy = fsmock.load(path.resolve(__dirname, 'mockRoot/deploy'));
127
+ }
128
+ fsmock(fsMockConf);
82
129
  };
130
+
83
131
  /**
84
132
  * resets mocks for API and FS
85
133
  *
@@ -87,6 +135,7 @@ exports.mockSetup = () => {
87
135
  */
88
136
  exports.mockReset = () => {
89
137
  auth.clearSessions();
138
+ fsmock.restore();
90
139
  apimock.restore();
91
140
  };
92
141
  /**