@@ -17,6 +17,7 @@ import {
17
17
FileResponse ,
18
18
MetadataApiRetrieve ,
19
19
MetadataApiRetrieveStatus ,
20
+ registry ,
20
21
RequestStatus ,
21
22
RetrieveResult ,
22
23
SourceComponent ,
@@ -25,9 +26,9 @@ import {
25
26
import { MetadataApiRetrieveError , MissingJobIdError } from '../../src/errors' ;
26
27
import { nls } from '../../src/i18n' ;
27
28
import { MOCK_ASYNC_RESULT , MOCK_DEFAULT_OUTPUT , stubMetadataRetrieve } from '../mock/client/transferOperations' ;
28
- import { mockRegistry , mockRegistryData , xmlInFolder } from '../mock/registry ' ;
29
- import { COMPONENT } from '../mock/registry/ type-constants/matchingContentFileConstants ' ;
30
- import { DECOMPOSED_COMPONENT } from '../mock/registry/ type-constants/decomposedConstants ' ;
29
+ import { xmlInFolder } from '../mock' ;
30
+ import { COMPONENT } from '../mock/type-constants/apexClassConstant ' ;
31
+ import { DECOMPOSED_COMPONENT } from '../mock/type-constants/customObjectConstant ' ;
31
32
32
33
const env = createSandbox ( ) ;
33
34
@@ -37,7 +38,7 @@ describe('MetadataApiRetrieve', () => {
37
38
describe ( 'Lifecycle' , ( ) => {
38
39
describe ( 'start' , ( ) => {
39
40
it ( 'should throw error if there are no components to retrieve' , async ( ) => {
40
- const toRetrieve = new ComponentSet ( [ ] , mockRegistry ) ;
41
+ const toRetrieve = new ComponentSet ( [ ] ) ;
41
42
const { operation } = await stubMetadataRetrieve ( env , {
42
43
toRetrieve,
43
44
merge : true ,
@@ -53,7 +54,7 @@ describe('MetadataApiRetrieve', () => {
53
54
} ) ;
54
55
55
56
it ( 'should throw error if packageNames list is empty' , async ( ) => {
56
- const toRetrieve = new ComponentSet ( [ ] , mockRegistry ) ;
57
+ const toRetrieve = new ComponentSet ( [ ] ) ;
57
58
const { operation } = await stubMetadataRetrieve ( env , {
58
59
toRetrieve,
59
60
merge : true ,
@@ -70,7 +71,7 @@ describe('MetadataApiRetrieve', () => {
70
71
} ) ;
71
72
72
73
it ( 'should call retrieve for unpackaged data' , async ( ) => {
73
- const toRetrieve = new ComponentSet ( [ COMPONENT ] , mockRegistry ) ;
74
+ const toRetrieve = new ComponentSet ( [ COMPONENT ] ) ;
74
75
const options = {
75
76
toRetrieve,
76
77
merge : true ,
@@ -87,7 +88,7 @@ describe('MetadataApiRetrieve', () => {
87
88
} ) ;
88
89
89
90
it ( 'should call retrieve for a package as string[]' , async ( ) => {
90
- const toRetrieve = new ComponentSet ( [ COMPONENT ] , mockRegistry ) ;
91
+ const toRetrieve = new ComponentSet ( [ COMPONENT ] ) ;
91
92
const options = {
92
93
toRetrieve,
93
94
packageOptions : [ 'MyPackage' ] ,
@@ -106,7 +107,7 @@ describe('MetadataApiRetrieve', () => {
106
107
} ) ;
107
108
108
109
it ( 'should call retrieve for a package as PackageOptions[] with name only' , async ( ) => {
109
- const toRetrieve = new ComponentSet ( [ COMPONENT ] , mockRegistry ) ;
110
+ const toRetrieve = new ComponentSet ( [ COMPONENT ] ) ;
110
111
const options = {
111
112
toRetrieve,
112
113
packageOptions : [ { name : 'MyPackage' } ] ,
@@ -125,7 +126,7 @@ describe('MetadataApiRetrieve', () => {
125
126
} ) ;
126
127
127
128
it ( 'should call retrieve for a package as PackageOptions[] with name and outputDir' , async ( ) => {
128
- const toRetrieve = new ComponentSet ( [ COMPONENT ] , mockRegistry ) ;
129
+ const toRetrieve = new ComponentSet ( [ COMPONENT ] ) ;
129
130
const options = {
130
131
toRetrieve,
131
132
packageOptions : [ { name : 'MyPackage' , outputDir : 'fake/output/dir' } ] ,
@@ -144,7 +145,7 @@ describe('MetadataApiRetrieve', () => {
144
145
} ) ;
145
146
146
147
it ( 'should return an AsyncResult' , async ( ) => {
147
- const toRetrieve = new ComponentSet ( [ COMPONENT ] , mockRegistry ) ;
148
+ const toRetrieve = new ComponentSet ( [ COMPONENT ] ) ;
148
149
const options = {
149
150
toRetrieve,
150
151
packageNames : [ 'MyPackage' ] ,
@@ -159,7 +160,7 @@ describe('MetadataApiRetrieve', () => {
159
160
} ) ;
160
161
161
162
it ( 'should set the retrieve ID' , async ( ) => {
162
- const toRetrieve = new ComponentSet ( [ COMPONENT ] , mockRegistry ) ;
163
+ const toRetrieve = new ComponentSet ( [ COMPONENT ] ) ;
163
164
const options = {
164
165
toRetrieve,
165
166
packageNames : [ 'MyPackage' ] ,
@@ -178,7 +179,7 @@ describe('MetadataApiRetrieve', () => {
178
179
const getPackageComponent = ( packageName : string ) : SourceComponent => {
179
180
const contentName = 'z.mcf' ;
180
181
const metaName = `${ contentName } -meta.xml` ;
181
- const type = mockRegistryData . types . matchingcontentfile ;
182
+ const type = registry . types . apexclass ;
182
183
return new SourceComponent (
183
184
{
184
185
name : 'z' ,
@@ -197,7 +198,7 @@ describe('MetadataApiRetrieve', () => {
197
198
198
199
it ( 'should retrieve zip and extract to directory' , async ( ) => {
199
200
const component = COMPONENT ;
200
- const toRetrieve = new ComponentSet ( [ component ] , mockRegistry ) ;
201
+ const toRetrieve = new ComponentSet ( [ component ] ) ;
201
202
const { operation, convertStub } = await stubMetadataRetrieve ( env , {
202
203
toRetrieve,
203
204
successes : toRetrieve ,
@@ -220,8 +221,8 @@ describe('MetadataApiRetrieve', () => {
220
221
const packageName = 'MyPackage' ;
221
222
const pkgComponent = getPackageComponent ( packageName ) ;
222
223
const fromSourceSpy = env . spy ( ComponentSet , 'fromSource' ) ;
223
- const toRetrieve = new ComponentSet ( [ component ] , mockRegistry ) ;
224
- const successesCompSet = new ComponentSet ( [ component , pkgComponent ] , mockRegistry ) ;
224
+ const toRetrieve = new ComponentSet ( [ component ] ) ;
225
+ const successesCompSet = new ComponentSet ( [ component , pkgComponent ] ) ;
225
226
const { operation, convertStub } = await stubMetadataRetrieve ( env , {
226
227
toRetrieve,
227
228
packageOptions : [ packageName ] ,
@@ -254,8 +255,8 @@ describe('MetadataApiRetrieve', () => {
254
255
const packageOutputDir = 'myPackageDir' ;
255
256
const pkgComponent = getPackageComponent ( packageName ) ;
256
257
const fromSourceSpy = env . spy ( ComponentSet , 'fromSource' ) ;
257
- const toRetrieve = new ComponentSet ( [ component ] , mockRegistry ) ;
258
- const successesCompSet = new ComponentSet ( [ component , pkgComponent ] , mockRegistry ) ;
258
+ const toRetrieve = new ComponentSet ( [ component ] ) ;
259
+ const successesCompSet = new ComponentSet ( [ component , pkgComponent ] ) ;
259
260
const { operation, convertStub } = await stubMetadataRetrieve ( env , {
260
261
toRetrieve,
261
262
packageOptions : [ { name : packageName , outputDir : packageOutputDir } ] ,
@@ -285,7 +286,7 @@ describe('MetadataApiRetrieve', () => {
285
286
it ( 'should save the temp directory if the environment variable is set' , async ( ) => {
286
287
try {
287
288
process . env . SFDX_MDAPI_TEMP_DIR = 'test' ;
288
- const toRetrieve = new ComponentSet ( [ COMPONENT ] , mockRegistry ) ;
289
+ const toRetrieve = new ComponentSet ( [ COMPONENT ] ) ;
289
290
const { operation, convertStub } = await stubMetadataRetrieve ( env , {
290
291
toRetrieve,
291
292
merge : true ,
@@ -303,7 +304,7 @@ describe('MetadataApiRetrieve', () => {
303
304
} ) ;
304
305
305
306
it ( 'should NOT save the temp directory if the environment variable is NOT set' , async ( ) => {
306
- const toRetrieve = new ComponentSet ( [ COMPONENT ] , mockRegistry ) ;
307
+ const toRetrieve = new ComponentSet ( [ COMPONENT ] ) ;
307
308
const { operation, convertStub } = await stubMetadataRetrieve ( env , {
308
309
toRetrieve,
309
310
merge : true ,
@@ -319,7 +320,7 @@ describe('MetadataApiRetrieve', () => {
319
320
320
321
it ( 'should retrieve zip and merge with existing components' , async ( ) => {
321
322
const component = COMPONENT ;
322
- const toRetrieve = new ComponentSet ( [ component ] , mockRegistry ) ;
323
+ const toRetrieve = new ComponentSet ( [ component ] ) ;
323
324
const { operation, convertStub } = await stubMetadataRetrieve ( env , {
324
325
toRetrieve,
325
326
merge : true ,
@@ -341,7 +342,7 @@ describe('MetadataApiRetrieve', () => {
341
342
} ) ;
342
343
343
344
it ( 'should construct a result object with retrieved components' , async ( ) => {
344
- const toRetrieve = new ComponentSet ( [ COMPONENT ] , mockRegistry ) ;
345
+ const toRetrieve = new ComponentSet ( [ COMPONENT ] ) ;
345
346
const { operation, response } = await stubMetadataRetrieve ( env , {
346
347
toRetrieve,
347
348
merge : true ,
@@ -356,7 +357,7 @@ describe('MetadataApiRetrieve', () => {
356
357
} ) ;
357
358
358
359
it ( 'should construct a result object with no components when components are forceIgnored' , async ( ) => {
359
- const toRetrieve = new ComponentSet ( [ COMPONENT ] , mockRegistry ) ;
360
+ const toRetrieve = new ComponentSet ( [ COMPONENT ] ) ;
360
361
toRetrieve . forceIgnoredPaths = new Set ( [ COMPONENT . xml , COMPONENT . content ] ) ;
361
362
const { operation } = await stubMetadataRetrieve ( env , {
362
363
toRetrieve,
@@ -371,7 +372,7 @@ describe('MetadataApiRetrieve', () => {
371
372
} ) ;
372
373
373
374
it ( 'should construct a result object with no components when no components are retrieved' , async ( ) => {
374
- const toRetrieve = new ComponentSet ( [ COMPONENT ] , mockRegistry ) ;
375
+ const toRetrieve = new ComponentSet ( [ COMPONENT ] ) ;
375
376
const { operation, response } = await stubMetadataRetrieve ( env , {
376
377
toRetrieve,
377
378
merge : true ,
@@ -384,7 +385,7 @@ describe('MetadataApiRetrieve', () => {
384
385
385
386
await operation . start ( ) ;
386
387
const result = await operation . pollStatus ( ) ;
387
- const compSet = new ComponentSet ( undefined , mockRegistry ) ;
388
+ const compSet = new ComponentSet ( undefined ) ;
388
389
const expected = new RetrieveResult ( response , compSet , toRetrieve ) ;
389
390
390
391
expect ( result ) . to . deep . equal ( expected ) ;
@@ -394,7 +395,7 @@ describe('MetadataApiRetrieve', () => {
394
395
395
396
describe ( 'checkStatus' , ( ) => {
396
397
it ( 'should throw an error when attempting to call checkStatus without an id set' , async ( ) => {
397
- const toRetrieve = new ComponentSet ( [ COMPONENT ] , mockRegistry ) ;
398
+ const toRetrieve = new ComponentSet ( [ COMPONENT ] ) ;
398
399
const { operation } = await stubMetadataRetrieve ( env , {
399
400
toRetrieve,
400
401
merge : true ,
@@ -474,7 +475,7 @@ describe('MetadataApiRetrieve', () => {
474
475
describe ( 'cancel' , ( ) => {
475
476
it ( 'should immediately stop polling' , async ( ) => {
476
477
const component = COMPONENT ;
477
- const components = new ComponentSet ( [ component ] , mockRegistry ) ;
478
+ const components = new ComponentSet ( [ component ] ) ;
478
479
const { operation, checkStatusStub } = await stubMetadataRetrieve ( env , {
479
480
toRetrieve : components ,
480
481
} ) ;
@@ -654,7 +655,7 @@ describe('MetadataApiRetrieve', () => {
654
655
const component = new SourceComponent (
655
656
{
656
657
name : 'OnlyContent' ,
657
- type : mockRegistryData . types . matchingcontentfile ,
658
+ type : registry . types . apexclass ,
658
659
content : COMPONENT . content ,
659
660
} ,
660
661
COMPONENT . tree
0 commit comments