@contrail/flexplm 1.4.0 → 1.5.0-alpha.14a4f1b

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 (112) hide show
  1. package/lib/cli/commands/compile.d.ts +4 -0
  2. package/lib/cli/commands/compile.js +73 -0
  3. package/lib/cli/commands/compile.spec.d.ts +1 -0
  4. package/lib/cli/commands/compile.spec.js +80 -0
  5. package/lib/cli/commands/create.d.ts +5 -0
  6. package/lib/cli/commands/create.js +77 -0
  7. package/lib/cli/commands/create.spec.d.ts +1 -0
  8. package/lib/cli/commands/create.spec.js +78 -0
  9. package/lib/cli/commands/upload.d.ts +17 -0
  10. package/lib/cli/commands/upload.js +228 -0
  11. package/lib/cli/commands/upload.spec.d.ts +1 -0
  12. package/lib/cli/commands/upload.spec.js +88 -0
  13. package/lib/cli/index.d.ts +5 -0
  14. package/lib/cli/index.js +70 -0
  15. package/lib/cli/index.spec.d.ts +1 -0
  16. package/lib/cli/index.spec.js +85 -0
  17. package/lib/cli/template/mapping-template.ts.template +62 -0
  18. package/lib/entity-processor/base-entity-processor.d.ts +65 -0
  19. package/lib/entity-processor/base-entity-processor.js +71 -0
  20. package/lib/entity-processor/base-entity-processor.spec.js +1 -0
  21. package/lib/index.d.ts +1 -0
  22. package/lib/index.js +1 -0
  23. package/lib/interfaces/mapping-file.d.ts +460 -0
  24. package/lib/interfaces/mapping-file.js +2 -0
  25. package/lib/publish/base-process-publish-assortment.d.ts +25 -0
  26. package/lib/publish/base-process-publish-assortment.js +60 -6
  27. package/lib/publish/base-process-publish-assortment.spec.js +22 -4
  28. package/lib/publish/mockData.js +5 -0
  29. package/lib/transform/identifier-conversion-spec-mockData.js +34 -6
  30. package/lib/transform/identifier-conversion.d.ts +36 -0
  31. package/lib/transform/identifier-conversion.js +37 -1
  32. package/lib/transform/identifier-conversion.spec.js +35 -0
  33. package/lib/util/config-defaults.d.ts +18 -0
  34. package/lib/util/config-defaults.js +25 -15
  35. package/lib/util/config-defaults.spec.js +56 -0
  36. package/lib/util/data-converter-spec-mockData.js +17 -3
  37. package/lib/util/data-converter.d.ts +102 -0
  38. package/lib/util/data-converter.js +195 -34
  39. package/lib/util/data-converter.spec.js +430 -0
  40. package/lib/util/error-response-object.d.ts +5 -0
  41. package/lib/util/error-response-object.js +7 -0
  42. package/lib/util/event-short-message-status.js +1 -0
  43. package/lib/util/federation.js +8 -0
  44. package/lib/util/flexplm-connect.d.ts +7 -0
  45. package/lib/util/flexplm-connect.js +14 -0
  46. package/lib/util/logger-config.js +1 -0
  47. package/lib/util/map-util-spec-mockData.js +17 -3
  48. package/lib/util/map-utils.d.ts +27 -0
  49. package/lib/util/map-utils.js +27 -0
  50. package/lib/util/thumbnail-util.d.ts +21 -0
  51. package/lib/util/thumbnail-util.js +28 -1
  52. package/lib/util/thumbnail-util.spec.js +6 -0
  53. package/lib/util/type-conversion-utils-spec-mockData.js +3 -3
  54. package/lib/util/type-conversion-utils.d.ts +151 -0
  55. package/lib/util/type-conversion-utils.js +154 -0
  56. package/lib/util/type-defaults.d.ts +69 -0
  57. package/lib/util/type-defaults.js +98 -4
  58. package/lib/util/type-defaults.spec.js +114 -4
  59. package/lib/util/type-utils.d.ts +21 -0
  60. package/lib/util/type-utils.js +23 -0
  61. package/lib/util/type-utils.spec.js +2 -0
  62. package/package.json +21 -6
  63. package/scripts/copy-template.js +10 -0
  64. package/.github/pull_request_template.md +0 -31
  65. package/.github/workflows/flexplm-lib.yml +0 -27
  66. package/.github/workflows/publish-to-npm.yml +0 -121
  67. package/CHANGELOG.md +0 -40
  68. package/publish.bat +0 -5
  69. package/publish.sh +0 -5
  70. package/src/entity-processor/base-entity-processor.spec.ts +0 -689
  71. package/src/entity-processor/base-entity-processor.ts +0 -583
  72. package/src/flexplm-request.ts +0 -28
  73. package/src/flexplm-utils.spec.ts +0 -27
  74. package/src/flexplm-utils.ts +0 -29
  75. package/src/index.ts +0 -22
  76. package/src/interfaces/interfaces.ts +0 -122
  77. package/src/interfaces/item-family-changes.ts +0 -67
  78. package/src/interfaces/publish-change-data.ts +0 -43
  79. package/src/publish/base-process-publish-assortment-callback.ts +0 -50
  80. package/src/publish/base-process-publish-assortment.spec.ts +0 -1992
  81. package/src/publish/base-process-publish-assortment.ts +0 -1134
  82. package/src/publish/mockData.ts +0 -4561
  83. package/src/transform/identifier-conversion-spec-mockData.ts +0 -496
  84. package/src/transform/identifier-conversion.spec.ts +0 -354
  85. package/src/transform/identifier-conversion.ts +0 -282
  86. package/src/util/config-defaults.spec.ts +0 -392
  87. package/src/util/config-defaults.ts +0 -97
  88. package/src/util/data-converter-spec-mockData.ts +0 -231
  89. package/src/util/data-converter.spec.ts +0 -1120
  90. package/src/util/data-converter.ts +0 -766
  91. package/src/util/error-response-object.spec.ts +0 -116
  92. package/src/util/error-response-object.ts +0 -50
  93. package/src/util/event-short-message-status.ts +0 -22
  94. package/src/util/federation.ts +0 -172
  95. package/src/util/flexplm-connect.spec.ts +0 -132
  96. package/src/util/flexplm-connect.ts +0 -208
  97. package/src/util/logger-config.ts +0 -20
  98. package/src/util/map-util-spec-mockData.ts +0 -231
  99. package/src/util/map-utils.spec.ts +0 -103
  100. package/src/util/map-utils.ts +0 -41
  101. package/src/util/mockData.ts +0 -101
  102. package/src/util/thumbnail-util.spec.ts +0 -508
  103. package/src/util/thumbnail-util.ts +0 -272
  104. package/src/util/type-conversion-utils-spec-mockData.ts +0 -272
  105. package/src/util/type-conversion-utils.spec.ts +0 -1031
  106. package/src/util/type-conversion-utils.ts +0 -490
  107. package/src/util/type-defaults.spec.ts +0 -669
  108. package/src/util/type-defaults.ts +0 -281
  109. package/src/util/type-utils.spec.ts +0 -227
  110. package/src/util/type-utils.ts +0 -144
  111. package/tsconfig.json +0 -24
  112. package/tslint.json +0 -57
@@ -1,1120 +0,0 @@
1
- const mockObj1234 = {
2
- id: 1234,
3
- typePath: 'color'
4
- };
5
- const mockObj2222 = {
6
- id: 2222,
7
- typePath: 'color'
8
- };
9
- const mockGetFunction = jest.fn((options) =>{
10
- return (options?.criteria?.id === 1234)
11
- ?[mockObj1234]
12
- :[mockObj2222];
13
- });
14
- jest.mock('@contrail/sdk', () => {
15
- const origModule = jest.requireActual('@contrail/sdk');
16
- return {
17
- __esModule: true,
18
- ...origModule,
19
- Entities: class {
20
- get = mockGetFunction;
21
- },
22
- };
23
- });
24
-
25
- import { Entities } from '@contrail/sdk';
26
- import { MapFileUtil } from '@contrail/transform-data';
27
- import { DataConverter } from './data-converter';
28
- import { FCConfig } from '../interfaces/interfaces';
29
- import { TypeConversionUtils } from './type-conversion-utils';
30
- import { MapUtil } from './map-utils';
31
-
32
- describe('getFlexPLMValue multi_select', () => {
33
- const config: FCConfig = {
34
- apiHost: 'host',
35
- userName: () => 'user',
36
- password: () => 'pass',
37
- urlContext: 'xxx',
38
- vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
39
- csrfEndpoint: '/servlet/rest/security/csrf',
40
- itemPreDevelopmentLifecycleStages: ['concept']
41
- };
42
-
43
- const mapFileUtil = new MapFileUtil(new Entities());
44
- const dc = new DataConverter(config, mapFileUtil);
45
- const enumAtt = {
46
- id: 'cJoZQvoj7dkfCBJq',
47
- propertyType: 'multi_select',
48
- slug: 'flexMultiSelect',
49
- label: 'Flex Multi Select',
50
- options: [
51
- {
52
- value: 'one',
53
- display: 'One'
54
- },
55
- {
56
- value: 'two',
57
- display: 'Two'
58
- },
59
- {
60
- value: 'three',
61
- display: 'Three'
62
- }
63
- ],
64
- };
65
-
66
- it('multi_select_null', async () => {
67
- const newData = {
68
- flexMultiSelect: null
69
- };
70
- const returnValue = await dc.getFlexPLMValue(enumAtt, newData, true);
71
- expect(returnValue).toEqual([]);
72
- });
73
-
74
- it('multi_select_no_values', async () => {
75
- const newData = {
76
- flexMultiSelect: []
77
- };
78
- const returnValue = await dc.getFlexPLMValue(enumAtt, newData, true);
79
- expect(returnValue).toEqual(newData.flexMultiSelect);
80
- });
81
-
82
- it('multi_select_two_values', async () => {
83
- const newData = {
84
- flexMultiSelect: ['one', 'three']
85
- };
86
- const optionValues = [
87
- { value: 'one', display: 'One' },
88
- { value: 'three', display: 'Three' }
89
- ];
90
- const returnValue = await dc.getFlexPLMValue(enumAtt, newData, true);
91
- expect(returnValue).toEqual(optionValues);
92
- });
93
- });
94
-
95
- describe('getEnumerationValue', () =>{
96
- const config: FCConfig = {
97
- apiHost: 'host',
98
- userName: () => 'user',
99
- password: () => 'pass',
100
- urlContext: 'xxx',
101
- vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
102
- csrfEndpoint: '/servlet/rest/security/csrf',
103
- itemPreDevelopmentLifecycleStages: ['concept']
104
- };
105
-
106
- const mapFileUtil = new MapFileUtil(new Entities());
107
- const dc = new DataConverter(config, mapFileUtil);
108
- const enumProp = {
109
- id: 'cJoZQvoj7dkfCBJq',
110
- propertyType: 'choice',
111
- slug: 'flexChoice',
112
- label: 'Flex Choice',
113
- options: [
114
- {
115
- value: 'one',
116
- display: 'One'
117
- },
118
- {
119
- value: 'two',
120
- display: 'Two'
121
- },
122
- {
123
- value: 'three',
124
- display: 'Three'
125
- }
126
- ],
127
- };
128
-
129
- const enumPropNoList = {
130
- id: 'cJoZQvoj7dkfCBJq',
131
- propertyType: 'choice',
132
- slug: 'flexChoice',
133
- label: 'Flex Choice',
134
- };
135
-
136
- it('match 1 key', () =>{
137
- const nd = 'one';
138
- const expectedValue = {value: 'one', display: 'One'};
139
-
140
- const returnValue = dc.getEnumerationValue(enumProp, nd);
141
- expect(returnValue).toEqual(expectedValue);
142
- });
143
-
144
- it('wrong key', () =>{
145
- const nd = 'one1';
146
- const expectedValue = {};
147
-
148
- const returnValue = dc.getEnumerationValue(enumProp, nd);
149
- expect(returnValue).toEqual(expectedValue);
150
- });
151
-
152
- it('property no list', () =>{
153
- const nd = 'one1';
154
- const expectedValue = {};
155
-
156
- const returnValue = dc.getEnumerationValue(enumPropNoList, nd);
157
- expect(returnValue).toEqual(expectedValue);
158
- });
159
-
160
- });
161
-
162
- describe('getEnumerationValue multi_select', () => {
163
- const config: FCConfig = {
164
- apiHost: 'host',
165
- userName: () => 'user',
166
- password: () => 'pass',
167
- urlContext: 'xxx',
168
- vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
169
- csrfEndpoint: '/servlet/rest/security/csrf',
170
- itemPreDevelopmentLifecycleStages: ['concept']
171
- };
172
-
173
- const mapFileUtil = new MapFileUtil(new Entities());
174
- const dc = new DataConverter(config, mapFileUtil);
175
- const enumAtt = {
176
- id: 'cJoZQvoj7dkfCBJq',
177
- propertyType: 'multi_select',
178
- slug: 'flexMultiSelect',
179
- label: 'Flex Multi Select',
180
- options: [
181
- {
182
- value: 'one',
183
- display: 'One'
184
- },
185
- {
186
- value: 'two',
187
- display: 'Two'
188
- },
189
- {
190
- value: 'three',
191
- display: 'Three'
192
- }
193
- ],
194
- };
195
-
196
-
197
- it('multi_select_null', async () => {
198
- const nd = null;
199
- const returnValue = await dc.getEnumerationValue(enumAtt, nd);
200
- expect(returnValue).toEqual([]);
201
- });
202
-
203
- it('multi_select_no_values', async () => {
204
- const nd = [];
205
- const returnValue = await dc.getEnumerationValue(enumAtt, nd);
206
- expect(returnValue).toEqual(nd);
207
- });
208
-
209
- it('multi select one string value', async () =>{
210
- const nd = 'one';
211
- const optionValues = [
212
- { value: 'one', display: 'One' }
213
- ];
214
- const returnValue = await dc.getEnumerationValue(enumAtt, nd);
215
- expect(returnValue).toEqual(optionValues);
216
- });
217
-
218
- it('multi_select_two_values', async () => {
219
- const nd = ['one', 'three'];
220
- const optionValues = [
221
- { value: 'one', display: 'One' },
222
- { value: 'three', display: 'Three' }
223
- ];
224
- const returnValue = await dc.getEnumerationValue(enumAtt, nd);
225
- expect(returnValue).toEqual(optionValues);
226
- });
227
-
228
- });
229
-
230
- describe('getPersistableChanges', () =>{
231
- const config: FCConfig = {
232
- apiHost: 'host',
233
- userName: () => 'user',
234
- password: () => 'pass',
235
- urlContext: 'xxx',
236
- vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
237
- csrfEndpoint: '/servlet/rest/security/csrf',
238
- itemPreDevelopmentLifecycleStages: ['concept']
239
- };
240
-
241
- const mapFileUtil = new MapFileUtil(new Entities());
242
- const dc = new DataConverter(config, mapFileUtil);
243
- it('no changes', () =>{
244
- const entity = {
245
- num: 1
246
- };
247
- const potentialChanges = {};
248
-
249
- const diffs = dc.getPersistableChanges(entity, potentialChanges);
250
- expect(Object.getOwnPropertyNames(diffs).length).toEqual(0);
251
- });
252
-
253
- it('same value', () =>{
254
- const entity = {
255
- str: 'test',
256
- num: 1
257
- };
258
- const potentialChanges = {
259
- str: 'test',
260
- num: 1
261
- };
262
-
263
- const diffs = dc.getPersistableChanges(entity, potentialChanges);
264
- expect(Object.getOwnPropertyNames(diffs).length).toEqual(0);
265
- });
266
-
267
- it('diff num value', () =>{
268
- const entity = {
269
- str: 'option 1 string-Changed',
270
- num: 12
271
- };
272
- const potentialChanges = {
273
- str: 'option 1 string-Changed',
274
- num: 1
275
- };
276
-
277
- const diffs = dc.getPersistableChanges(entity, potentialChanges);
278
- expect(Object.getOwnPropertyNames(diffs).length).toEqual(1);
279
- expect(diffs['num']).toEqual(potentialChanges['num']);
280
- });
281
-
282
- it('zero num value', () =>{
283
- const entity = {
284
- str: 'option 1 string-Changed',
285
- num: 12
286
- };
287
- const potentialChanges = {
288
- str: 'option 1 string-Changed',
289
- num: 0
290
- };
291
-
292
- const diffs = dc.getPersistableChanges(entity, potentialChanges);
293
- expect(Object.getOwnPropertyNames(diffs).length).toEqual(1);
294
- expect(diffs['num']).toEqual(potentialChanges['num']);
295
- });
296
-
297
- it('diff str value', () =>{
298
- const entity = {
299
- str: 'test',
300
- num: 1
301
- };
302
- const potentialChanges = {
303
- str: 'test-1',
304
- num: 1
305
- };
306
-
307
- const diffs = dc.getPersistableChanges(entity, potentialChanges);
308
- expect(Object.getOwnPropertyNames(diffs).length).toEqual(1);
309
- expect(diffs['str']).toEqual(potentialChanges['str']);
310
- });
311
-
312
- it('empty str value', () =>{
313
- const entity = {
314
- str: 'test',
315
- num: 1
316
- };
317
- const potentialChanges = {
318
- str: '',
319
- num: 1
320
- };
321
-
322
- const diffs = dc.getPersistableChanges(entity, potentialChanges);
323
- expect(Object.getOwnPropertyNames(diffs).length).toEqual(1);
324
- expect(diffs['str']).toBeNull();
325
- });
326
-
327
- });
328
-
329
- describe('getObjectReferenceValue cache', () =>{
330
- const config: FCConfig = {
331
- apiHost: 'host',
332
- userName: () => 'user',
333
- password: () => 'pass',
334
- urlContext: 'xxx',
335
- vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
336
- csrfEndpoint: '/servlet/rest/security/csrf',
337
- itemPreDevelopmentLifecycleStages: ['concept']
338
- };
339
-
340
- const mapFileUtil = new MapFileUtil(new Entities());
341
- const dc = new DataConverter(config, mapFileUtil);
342
- const ref1Prop = {
343
- id: 'cJoZQvoj7dkfCBJq',
344
- propertyType: 'object_reference',
345
- slug: 'ref1',
346
- label: 'Object Ref#1',
347
- referencedTypeRootSlug: 'color'
348
-
349
- };
350
- const ref2Prop = {
351
- id: 'cJoZQvoj7dkfCBJq',
352
- propertyType: 'object_reference',
353
- slug: 'ref2',
354
- label: 'Object Ref#2',
355
- referencedTypeRootSlug: 'color'
356
-
357
- };
358
- const ref3Prop = {
359
- id: 'cJoZQvoj7dkfCBJq',
360
- propertyType: 'object_reference',
361
- slug: 'ref3',
362
- label: 'Object Ref#3',
363
- referencedTypeRootSlug: 'color'
364
-
365
- };
366
- const newData = {
367
- ref1Id: 1234,
368
- ref2Id: 2222,
369
- ref3Id: 1234
370
- };
371
-
372
- it('cache hit', async () =>{
373
- const oobFunction = dc.getFlexPLMObjectData;
374
- try {
375
- dc.getFlexPLMObjectData = async (newData, /*dataToSkip: string[], inflateObjRef: boolean*/) => {
376
- return newData;
377
- };
378
- mockGetFunction.mockClear();
379
-
380
- const r1 = await dc.getObjectReferenceValue(ref1Prop, newData, true);
381
- const r2 = await dc.getObjectReferenceValue(ref2Prop, newData, true);
382
- const r3 = await dc.getObjectReferenceValue(ref3Prop, newData, true);
383
-
384
- expect(mockGetFunction).toHaveBeenCalledTimes(2);
385
- expect(r1).toEqual(mockObj1234);
386
- expect(r2).toEqual(mockObj2222);
387
- expect(r3).toEqual(mockObj1234);
388
-
389
- } finally {
390
- dc.getFlexPLMObjectData = oobFunction;
391
- }
392
- });
393
- });
394
- describe('getObjectReferenceValue bad value', () =>{
395
- const config: FCConfig = {
396
- apiHost: 'host',
397
- userName: () => 'user',
398
- password: () => 'pass',
399
- urlContext: 'xxx',
400
- vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
401
- csrfEndpoint: '/servlet/rest/security/csrf',
402
- itemPreDevelopmentLifecycleStages: ['concept']
403
- };
404
-
405
- const mapFileUtil = new MapFileUtil(new Entities());
406
- const dc = new DataConverter(config, mapFileUtil);
407
- const ref1Prop = {
408
- id: 'cJoZQvoj7dkfCBJq',
409
- propertyType: 'object_reference',
410
- slug: 'ref1',
411
- label: 'Object Ref#1',
412
- referencedTypeRootSlug: 'color'
413
-
414
- };
415
- const ref2Prop = {
416
- id: 'cJoZQvoj7dkfCBJq',
417
- propertyType: 'object_reference',
418
- slug: 'ref2',
419
- label: 'Object Ref#2',
420
- referencedTypeRootSlug: 'color'
421
-
422
- };
423
- const ref3Prop = {
424
- id: 'cJoZQvoj7dkfCBJq',
425
- propertyType: 'object_reference',
426
- slug: 'ref3',
427
- label: 'Object Ref#3',
428
- referencedTypeRootSlug: 'color'
429
-
430
- };
431
- const newData = {
432
- ref1Id: 1234,
433
- ref2Id: 2222,
434
- ref3Id: 1234,
435
- ref3: 'old value'
436
- };
437
-
438
- it('old string value', async () =>{
439
- const oobFunction = dc.getFlexPLMObjectData;
440
- try {
441
- dc.getFlexPLMObjectData = async (newData, /*dataToSkip: string[], inflateObjRef: boolean*/) => {
442
- return newData;
443
- };
444
- mockGetFunction.mockClear();
445
- const r3 = await dc.getObjectReferenceValue(ref3Prop, newData, true);
446
- expect(r3).toEqual(mockObj1234);
447
-
448
- } finally {
449
- dc.getFlexPLMObjectData = oobFunction;
450
- }
451
- });
452
-
453
- it('only id', async () =>{
454
- const oobFunction = dc.getFlexPLMObjectData;
455
- try {
456
- dc.getFlexPLMObjectData = async (newData, /*dataToSkip: string[], inflateObjRef: boolean*/) => {
457
- return newData;
458
- };
459
- mockGetFunction.mockClear();
460
- const r2 = await dc.getObjectReferenceValue(ref2Prop, newData, true);
461
- expect(r2).toEqual(mockObj2222);
462
-
463
- } finally {
464
- dc.getFlexPLMObjectData = oobFunction;
465
- }
466
- });
467
-
468
- it('already references object', async () =>{
469
- const testData = {
470
- ref1Id: 1234,
471
- ref1: mockObj1234,
472
- ref2Id: 2222,
473
- ref3Id: 1234,
474
- ref3: 'old value'
475
- };
476
-
477
- const oobFunction = dc.getFlexPLMObjectData;
478
- try {
479
- dc.getFlexPLMObjectData = async (newData, /*dataToSkip: string[], inflateObjRef: boolean*/) => {
480
- return newData;
481
- };
482
- mockGetFunction.mockClear();
483
- const r1 = await dc.getObjectReferenceValue(ref1Prop, testData, true);
484
- expect(r1).toEqual(mockObj1234);
485
-
486
- } finally {
487
- dc.getFlexPLMObjectData = oobFunction;
488
- }
489
- });
490
-
491
- it('old string value, no refId', async () =>{
492
- const testData = {
493
- ref1: 'old value'
494
- };
495
-
496
- const oobFunction = dc.getFlexPLMObjectData;
497
- try {
498
- dc.getFlexPLMObjectData = async (newData, /*dataToSkip: string[], inflateObjRef: boolean*/) => {
499
- return newData;
500
- };
501
- mockGetFunction.mockClear();
502
- const r1 = await dc.getObjectReferenceValue(ref1Prop, testData, true);
503
- expect(r1).toEqual({});
504
-
505
- } finally {
506
- dc.getFlexPLMObjectData = oobFunction;
507
- }
508
- });
509
-
510
- });
511
-
512
- describe('getObjectReferenceValue - use mapping', () => {
513
-
514
- const maps = require('./data-converter-spec-mockData');
515
- const mapping = maps['mapping'];
516
- const config: FCConfig = {
517
- apiHost: 'host',
518
- userName: () => 'user',
519
- password: () => 'pass',
520
- urlContext: 'xxx',
521
- transformMapFile: 'file1',
522
- vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
523
- csrfEndpoint: '/servlet/rest/security/csrf',
524
- itemPreDevelopmentLifecycleStages: ['concept']
525
- } as any;
526
-
527
- const mapFileUtil = new MapFileUtil(new Entities());
528
- const dc = new DataConverter(config, mapFileUtil);
529
-
530
- const ref1Prop = {
531
- id: 'cJoZQvoj7dkfCBJq',
532
- propertyType: 'object_reference',
533
- slug: 'ref1',
534
- label: 'Object Ref#1',
535
- referencedTypeRootSlug: 'color'
536
-
537
- };
538
- const ref2Prop = {
539
- id: 'cJoZQvoj7dkfCBJq',
540
- propertyType: 'object_reference',
541
- slug: 'ref2',
542
- label: 'Object Ref#2',
543
- referencedTypeRootSlug: 'color'
544
-
545
- };
546
- const ref3Prop = {
547
- id: 'cJoZQvoj7dkfCBJq',
548
- propertyType: 'object_reference',
549
- slug: 'ref3',
550
- label: 'Object Ref#3',
551
- referencedTypeRootSlug: 'color'
552
-
553
- };
554
- const newData = {
555
- ref1Id: 1234,
556
- ref1: mockObj1234,
557
- ref2Id: 2222,
558
- ref2: mockObj2222,
559
- ref3Id: 1234,
560
- ref3: mockObj1234
561
- };
562
-
563
- it('mapping test', async () =>{
564
- const oobFunction = dc.getFlexPLMObjectData;
565
- try {
566
- dc.getFlexPLMObjectData = async (newData, /*dataToSkip: string[], inflateObjRef: boolean*/) => {
567
- return newData;
568
- };
569
- mockGetFunction.mockClear();
570
-
571
- let spyGetObjectClass = jest.spyOn(TypeConversionUtils, 'getObjectClass')
572
- .mockImplementation(async () => {return 'LCSColor'});
573
-
574
- let spyGetObjectTypePath = jest.spyOn(TypeConversionUtils, 'getObjectTypePath')
575
- .mockImplementation(async () => {return 'Color'});
576
-
577
- let spyGetMapKey = jest.spyOn(TypeConversionUtils, 'getMapKey')
578
- .mockImplementation(async () => {return 'LCSColor'});
579
-
580
- let spyApplyTransformMap = jest.spyOn(MapUtil, 'applyTransformMap')
581
- .mockImplementation(async (...args) => {return args[2]});
582
-
583
- const r1 = await dc.getObjectReferenceValue(ref1Prop, newData, true);
584
- const r2 = await dc.getObjectReferenceValue(ref2Prop, newData, true);
585
-
586
- expect(spyGetObjectClass).toHaveBeenCalledTimes(2);
587
- expect(spyGetObjectTypePath).toHaveBeenCalledTimes(2);
588
- expect(spyGetMapKey).toHaveBeenCalledTimes(2);
589
- expect(spyApplyTransformMap).toHaveBeenCalledTimes(2);
590
-
591
- } finally {
592
- dc.getFlexPLMObjectData = oobFunction;
593
- }
594
- });
595
- });
596
-
597
- describe('setEnumerationKeys', () =>{
598
- const config: FCConfig = {
599
- apiHost: 'host',
600
- userName: () => 'user',
601
- password: () => 'pass',
602
- urlContext: 'xxx',
603
- vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
604
- csrfEndpoint: '/servlet/rest/security/csrf',
605
- itemPreDevelopmentLifecycleStages: ['concept']
606
- };
607
-
608
- const mapFileUtil = new MapFileUtil(new Entities());
609
- const dc = new DataConverter(config, mapFileUtil);
610
- const enumProp = {
611
- id: 'cJoZQvoj7dkfCBJq',
612
- propertyType: 'multi_select',
613
- slug: 'flexMultiSelect',
614
- label: 'Flex Multi Select',
615
- options: [
616
- {
617
- value: 'one',
618
- display: 'One'
619
- },
620
- {
621
- value: 'two',
622
- display: 'Two'
623
- },
624
- {
625
- value: 'three',
626
- display: 'Three'
627
- }
628
- ],
629
- };
630
-
631
- const enumPropNoList = {
632
- id: 'cJoZQvoj7dkfCBJq',
633
- propertyType: 'multi_select',
634
- slug: 'flexMultiSelect',
635
- label: 'Flex Multi Select',
636
- };
637
-
638
- it('match 1 key', () =>{
639
- const newData = [{value: 'one', display: 'One'}];
640
-
641
- const returnValue = dc.setEnumerationKeys(enumProp, newData, false);
642
- expect(returnValue).toEqual(['one']);
643
- });
644
-
645
- it('match 2 key', () =>{
646
- const newData = [{value: 'one', display: 'One'}, {value: 'two', display: 'Two'}];
647
-
648
- const returnValue = dc.setEnumerationKeys(enumProp, newData, false);
649
- expect(returnValue).toEqual(['one', 'two']);
650
- });
651
-
652
- it('match 1 display', () =>{
653
- const newData = [{value: 'one', display: 'One'}];
654
-
655
- const returnValue = dc.setEnumerationKeys(enumProp, newData, true);
656
- expect(returnValue).toEqual(['one']);
657
- });
658
-
659
- it('match 2 display', () =>{
660
- const newData = [{value: 'one', display: 'One'}, {value: 'two', display: 'Two'}];
661
-
662
- const returnValue = dc.setEnumerationKeys(enumProp, newData, true);
663
- expect(returnValue).toEqual(['one', 'two']);
664
- });
665
-
666
- it('property no list', () =>{
667
- const newData = [{value: 'one', display: 'One'}, {value: 'two', display: 'Two'}];
668
-
669
- const returnValue = dc.setEnumerationKeys(enumPropNoList, newData, false);
670
- expect(returnValue).toEqual([]);
671
- });
672
-
673
- });
674
-
675
- describe('checkKeysAndValues', () =>{
676
- const config: FCConfig = {
677
- apiHost: 'host',
678
- userName: () => 'user',
679
- password: () => 'pass',
680
- urlContext: 'xxx',
681
- vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
682
- csrfEndpoint: '/servlet/rest/security/csrf',
683
- itemPreDevelopmentLifecycleStages: ['concept']
684
- };
685
-
686
- const mapFileUtil = new MapFileUtil(new Entities());
687
- const dc = new DataConverter(config, mapFileUtil);
688
- const groupData = [
689
- {name: 'Group 1', typePath: 'custom-entity:grouping'},
690
- {name: 'Group 2', typePath: 'custom-entity:grouping'},
691
- {name: 'Group 2', typePath: 'custom-entity:grouping'},
692
- {name: 'Group 4', typePath: 'custom-entity:grouping'},
693
- {name: 'Group 4', typePath: 'custom-entity:grouping:sub'},
694
- {name: 'Group 5', typePath: 'custom-entity:grouping:sub'}
695
- ];
696
- //item:product:newBalance:accessories, item:product:newBalance:apparel
697
-
698
- it('Group 1', () =>{
699
- const criteria = {
700
- name: 'Group 1'
701
- }
702
- const typePath = 'custom-entity:grouping';
703
- const results = dc.checkKeysAndValues(criteria, groupData, typePath);
704
- expect(results.length).toBe(1);
705
- });
706
-
707
- it('Group 5 - sub type of typePath', () =>{
708
- const criteria = {
709
- name: 'Group 5'
710
- }
711
- const typePath = 'custom-entity:grouping';
712
- const results = dc.checkKeysAndValues(criteria, groupData, typePath);
713
- expect(results.length).toBe(1);
714
- });
715
- it('Group 2 - returns the 2 matching', () =>{
716
- const criteria = {
717
- name: 'Group 2'
718
- }
719
- const typePath = 'custom-entity:grouping';
720
- const results = dc.checkKeysAndValues(criteria, groupData, typePath);
721
- expect(results.length).toBe(2);
722
- });
723
-
724
- it('2 Same Name - but 1 is a sub type; returns 2', () =>{
725
- const criteria = {
726
- name: 'Group 4'
727
- }
728
- const typePath = 'custom-entity:grouping';
729
- const results = dc.checkKeysAndValues(criteria, groupData, typePath);
730
- expect(results.length).toBe(2);
731
- });
732
-
733
- it('2 Same Name - but 1 wrong type', () =>{
734
- const criteria = {
735
- name: 'Group 1'
736
- }
737
- const testData =[...groupData];
738
- testData.push({name: 'Group 1', typePath: 'custom-entity:label'});
739
- const typePath = 'custom-entity:grouping';
740
- const results = dc.checkKeysAndValues(criteria, testData, typePath);
741
- expect(results.length).toBe(1);
742
- });
743
-
744
- it('first & last entity have the wrong typePath', () =>{
745
- const criteria ={
746
- objectId: "2562",
747
- };
748
- const typePath = 'custom-entity:group2';
749
-
750
- const testData = [
751
- {"typePath":"custom-entity:group1","name":"BLACK (BK)","id":"o1v2rh8olgQ78GcL","objectId":"2562","entityType":"custom-entity"},
752
- {"typePath":"custom-entity:group2","name":"BLACK (BK)","id":"t5n22S2gqswe8GcL","objectId":"2562","entityType":"custom-entity"},
753
- {"typePath":"custom-entity:group1","name":"BLACK (BK)","id":"t5rh8o2gqswk3drt","objectId":"2562","entityType":"custom-entity"}
754
- ];
755
- const results = dc.checkKeysAndValues(criteria, testData, typePath);
756
- expect(results.length).toBe(1);
757
-
758
- });
759
- });
760
-
761
- describe('filterOutArchivedAndTrashedEntities', () =>{
762
- const config: FCConfig = {
763
- apiHost: 'host',
764
- userName: () => 'user',
765
- password: () => 'pass',
766
- urlContext: 'xxx',
767
- vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
768
- csrfEndpoint: '/servlet/rest/security/csrf',
769
- itemPreDevelopmentLifecycleStages: ['concept']
770
- };
771
-
772
- const mapFileUtil = new MapFileUtil(new Entities());
773
- const dc = new DataConverter(config, mapFileUtil);
774
-
775
- it('filter out isArchived and isTrashed entities', () =>{
776
- const entities = [
777
- {id: '1', name: 'Entity 1', isArchived: false, isTrashed: false},
778
- {id: '2', name: 'Entity 2', isArchived: true, isTrashed: false},
779
- {id: '3', name: 'Entity 3', isArchived: false, isTrashed: true},
780
- {id: '4', name: 'Entity 4', isArchived: false, isTrashed: false}
781
- ];
782
-
783
- const filteredEntities = dc.filterOutArchivedAndTrashedEntities(entities);
784
- expect(filteredEntities.length).toBe(2);
785
- expect(filteredEntities).toEqual([
786
- {id: '1', name: 'Entity 1', isArchived: false, isTrashed: false},
787
- {id: '4', name: 'Entity 4', isArchived: false, isTrashed: false}
788
- ]);
789
- });
790
- it('no entities to filter', () =>{
791
- const entities = [];
792
- const filteredEntities = dc.filterOutArchivedAndTrashedEntities(entities);
793
- expect(filteredEntities.length).toBe(0);
794
- });
795
- it('all entities are archived or trashed', () =>{
796
- const entities = [
797
- {id: '1', name: 'Entity 1', isArchived: true, isTrashed: false},
798
- {id: '2', name: 'Entity 2', isArchived: false, isTrashed: true}
799
- ];
800
-
801
- const filteredEntities = dc.filterOutArchivedAndTrashedEntities(entities);
802
- expect(filteredEntities.length).toBe(0);
803
- });
804
- });
805
-
806
- describe('setUserListValue', () =>{
807
- const config: FCConfig = {
808
- apiHost: 'host',
809
- userName: () => 'user',
810
- password: () => 'pass',
811
- urlContext: 'xxx',
812
- vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
813
- csrfEndpoint: '/servlet/rest/security/csrf',
814
- itemPreDevelopmentLifecycleStages: ['concept']
815
- };
816
- const userListProp1 = {};
817
- const userEmailMapping = [
818
- {
819
- id: "gxgr46kvdeEOn4cH",
820
- email: "jessica.smith@vibeiq.com"
821
- },
822
-
823
- {
824
- id: "Rl5D0sjuAwelScEK",
825
- email: "adam.smith@vibeiq.com"
826
- }
827
- ];
828
-
829
- const mapFileUtil = new MapFileUtil(new Entities());
830
- const dc = new DataConverter(config, mapFileUtil);
831
- let spyGetUserByEmail = jest.spyOn(dc, 'getUserByEmail')
832
- .mockImplementation(async (nd) => {
833
- let emaildInput = nd?.email.toLowerCase();
834
- return userEmailMapping.find((user) => user.email === emaildInput);
835
- });
836
- let spyProcessGroupMemberCheck = jest.spyOn(dc, 'processGroupMemberCheck')
837
- .mockImplementation(async (nd) => { return; });
838
-
839
- afterEach(() => {
840
- spyGetUserByEmail.mockClear();
841
- spyProcessGroupMemberCheck.mockClear();
842
- DataConverter.clearStaticUserCache();
843
- });
844
- afterAll(() => {
845
- spyGetUserByEmail.mockRestore();
846
- spyProcessGroupMemberCheck.mockRestore();
847
- });
848
-
849
- it('no value', async () =>{
850
- const newData = {};
851
- const returnValue = await dc.setUserListValue(userListProp1, newData);
852
-
853
- expect(returnValue).toEqual('');
854
- });
855
-
856
- it('miss cache', async () =>{
857
- const newData = {email: 'adam.smith@vibeiq.com'};
858
- const returnValue = await dc.setUserListValue(userListProp1, newData);
859
- console.log('returnValue', JSON.stringify(returnValue));
860
- expect(returnValue).toEqual('Rl5D0sjuAwelScEK');
861
- expect(spyGetUserByEmail).toHaveBeenCalledTimes(1);
862
- expect(spyProcessGroupMemberCheck).toHaveBeenCalledTimes(1);
863
- });
864
-
865
- it('miss cache - two different emails', async () =>{
866
- let newData = {email: 'adam.smith@vibeiq.com'};
867
- let returnValue = await dc.setUserListValue(userListProp1, newData);
868
- expect(returnValue).toEqual('Rl5D0sjuAwelScEK');
869
- expect(spyGetUserByEmail).toHaveBeenCalledTimes(1);
870
- expect(spyProcessGroupMemberCheck).toHaveBeenCalledTimes(1);
871
-
872
- newData = {email: 'jessica.smith@vibeiq.com'};
873
- returnValue = await dc.setUserListValue(userListProp1, newData);
874
- expect(spyGetUserByEmail).toHaveBeenCalledTimes(2);
875
- expect(spyProcessGroupMemberCheck).toHaveBeenCalledTimes(2);
876
- });
877
-
878
- it('hit cache same email', async () =>{
879
- const newData = {email: 'adam.smith@vibeiq.com'};
880
- let returnValue = await dc.setUserListValue(userListProp1, newData);
881
- expect(returnValue).toEqual('Rl5D0sjuAwelScEK');
882
- expect(spyGetUserByEmail).toHaveBeenCalledTimes(1);
883
- expect(spyProcessGroupMemberCheck).toHaveBeenCalledTimes(1);
884
-
885
- returnValue = await dc.setUserListValue(userListProp1, newData);
886
- expect(returnValue).toEqual('Rl5D0sjuAwelScEK');
887
- expect(spyGetUserByEmail).toHaveBeenCalledTimes(1);
888
- expect(spyProcessGroupMemberCheck).toHaveBeenCalledTimes(2);
889
- });
890
-
891
- it('hit cache same email - new DataConverter entity', async () =>{
892
- const newData = {email: 'adam.smith@vibeiq.com'};
893
- let returnValue = await dc.setUserListValue(userListProp1, newData);
894
- expect(returnValue).toEqual('Rl5D0sjuAwelScEK');
895
- expect(spyGetUserByEmail).toHaveBeenCalledTimes(1);
896
- expect(spyProcessGroupMemberCheck).toHaveBeenCalledTimes(1);
897
-
898
- const dc2 = new DataConverter(config, mapFileUtil);
899
- let spyGetUserByEmail2 = jest.spyOn(dc2, 'getUserByEmail')
900
- .mockImplementation(async (nd) => {
901
- let emaildInput = nd?.email.toLowerCase();
902
- return userEmailMapping.find((user) => user.email === emaildInput);
903
- });
904
- let spyProcessGroupMemberCheck2 = jest.spyOn(dc2, 'processGroupMemberCheck')
905
- .mockImplementation(async (nd) => { return; });
906
-
907
- returnValue = await dc2.setUserListValue(userListProp1, newData);
908
- expect(returnValue).toEqual('Rl5D0sjuAwelScEK');
909
- expect(spyGetUserByEmail2).toHaveBeenCalledTimes(0);
910
- expect(spyProcessGroupMemberCheck2).toHaveBeenCalledTimes(1);
911
-
912
- spyGetUserByEmail2.mockRestore();
913
- spyProcessGroupMemberCheck2.mockRestore();
914
- });
915
-
916
- });
917
-
918
- describe('getUserListValue', () =>{
919
- const config: FCConfig = {
920
- apiHost: 'host',
921
- userName: () => 'user',
922
- password: () => 'pass',
923
- urlContext: 'xxx',
924
- vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
925
- csrfEndpoint: '/servlet/rest/security/csrf',
926
- itemPreDevelopmentLifecycleStages: ['concept']
927
- };
928
- const userListProp1 = {
929
- slug: 'userList1'
930
- };
931
- const userEmailMapping = [
932
- {
933
- id: "gxgr46kvdeEOn4cH",
934
- email: "jessica.smith@vibeiq.com",
935
- first: 'Jessica',
936
- last: 'Smith'
937
- },
938
-
939
- {
940
- id: "Rl5D0sjuAwelScEK",
941
- email: "adam.smith@vibeiq.com",
942
- first: 'Adam',
943
- last: 'Smith'
944
- }
945
- ];
946
-
947
- const mapFileUtil = new MapFileUtil(new Entities());
948
- const dc = new DataConverter(config, mapFileUtil);
949
-
950
- //getUserById
951
- let spyGetUserById = jest.spyOn(dc, 'getUserById')
952
- .mockImplementation(async (nd) => {
953
- return userEmailMapping.find((user) => user.id === nd);
954
- });
955
-
956
- afterEach(() => {
957
- spyGetUserById.mockClear();
958
- DataConverter.clearStaticUserCache();
959
- });
960
- afterAll(() => {
961
- spyGetUserById.mockRestore();
962
- });
963
-
964
- it('no value', async () =>{
965
- const newData = {};
966
- const returnValue = await dc.getUserListValue(userListProp1, newData);
967
-
968
- expect(returnValue).toEqual({});
969
- });
970
-
971
- it('miss cache', async () =>{
972
- const newData = {
973
- userList1Id: 'gxgr46kvdeEOn4cH'
974
- };
975
-
976
- const returnValue = await dc.getUserListValue(userListProp1, newData);
977
-
978
- expect(spyGetUserById).toHaveBeenCalledTimes(1);
979
- expect(returnValue.email).toEqual('jessica.smith@vibeiq.com');
980
- expect(returnValue.firstName).toEqual('Jessica');
981
- expect(returnValue.lastName).toEqual('Smith');
982
-
983
- });
984
-
985
- it('miss cache - two different emails', async () =>{
986
- let newData = { userList1Id: 'gxgr46kvdeEOn4cH'};
987
- let returnValue = await dc.getUserListValue(userListProp1, newData);
988
-
989
- expect(spyGetUserById).toHaveBeenCalledTimes(1);
990
- expect(returnValue.email).toEqual('jessica.smith@vibeiq.com');
991
- expect(returnValue.firstName).toEqual('Jessica');
992
- expect(returnValue.lastName).toEqual('Smith');
993
-
994
- newData = { userList1Id: 'Rl5D0sjuAwelScEK' };
995
- returnValue = await dc.getUserListValue(userListProp1, newData);
996
-
997
- expect(spyGetUserById).toHaveBeenCalledTimes(2);
998
- expect(returnValue.email).toEqual('adam.smith@vibeiq.com');
999
- expect(returnValue.firstName).toEqual('Adam');
1000
- expect(returnValue.lastName).toEqual('Smith');
1001
- });
1002
-
1003
- it('hit cache same email', async () =>{
1004
- const newData = { userList1Id: 'gxgr46kvdeEOn4cH'};
1005
- let returnValue = await dc.getUserListValue(userListProp1, newData);
1006
-
1007
- expect(spyGetUserById).toHaveBeenCalledTimes(1);
1008
- expect(returnValue.email).toEqual('jessica.smith@vibeiq.com');
1009
- expect(returnValue.firstName).toEqual('Jessica');
1010
- expect(returnValue.lastName).toEqual('Smith');
1011
-
1012
- returnValue = await dc.getUserListValue(userListProp1, newData);
1013
- expect(spyGetUserById).toHaveBeenCalledTimes(1);
1014
- expect(returnValue.email).toEqual('jessica.smith@vibeiq.com');
1015
- expect(returnValue.firstName).toEqual('Jessica');
1016
- expect(returnValue.lastName).toEqual('Smith');
1017
- });
1018
-
1019
- it('hit cache same email - new DataConverter entity', async () =>{
1020
- const newData = { userList1Id: 'gxgr46kvdeEOn4cH'};
1021
- let returnValue = await dc.getUserListValue(userListProp1, newData);
1022
-
1023
- expect(spyGetUserById).toHaveBeenCalledTimes(1);
1024
- expect(returnValue.email).toEqual('jessica.smith@vibeiq.com');
1025
- expect(returnValue.firstName).toEqual('Jessica');
1026
- expect(returnValue.lastName).toEqual('Smith');
1027
-
1028
- const dc2 = new DataConverter(config, mapFileUtil);
1029
- let spyGetUserById2 = jest.spyOn(dc2, 'getUserById')
1030
- .mockImplementation(async (nd) => {
1031
- return userEmailMapping.find((user) => user.id === nd);
1032
- });
1033
-
1034
- returnValue = await dc2.getUserListValue(userListProp1, newData);
1035
- expect(spyGetUserById2).toHaveBeenCalledTimes(0);
1036
- expect(returnValue.email).toEqual('jessica.smith@vibeiq.com');
1037
- expect(returnValue.firstName).toEqual('Jessica');
1038
- expect(returnValue.lastName).toEqual('Smith');
1039
- });
1040
-
1041
- });
1042
-
1043
-
1044
- describe('getFlexPLMValue size_range', () => {
1045
- const config: FCConfig = {
1046
- apiHost: 'host',
1047
- userName: () => 'user',
1048
- password: () => 'pass',
1049
- urlContext: 'xxx',
1050
- vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
1051
- csrfEndpoint: '/servlet/rest/security/csrf',
1052
- itemPreDevelopmentLifecycleStages: ['concept']
1053
- };
1054
-
1055
- const mapFileUtil = new MapFileUtil(new Entities());
1056
- const dc = new DataConverter(config, mapFileUtil);
1057
-
1058
- const sizeRangeProp = {
1059
- propertyType: 'size_range',
1060
- slug: 'sizeRange',
1061
- label: 'Size Range',
1062
- };
1063
-
1064
- it('returns sizeRange object when value is present', async () => {
1065
- const newData = { sizeRange: { sizes: ['PRE', 'NB'] } };
1066
- const returnValue = await dc.getFlexPLMValue(sizeRangeProp, newData, true);
1067
- expect(returnValue).toEqual({ sizes: ['PRE', 'NB'] });
1068
- });
1069
-
1070
- it('returns null when sizeRange is null', async () => {
1071
- const newData = { sizeRange: null };
1072
- const returnValue = await dc.getFlexPLMValue(sizeRangeProp, newData, true);
1073
- expect(returnValue).toBeNull();
1074
- });
1075
-
1076
- it('returns undefined when sizeRange is missing', async () => {
1077
- const newData = {};
1078
- const returnValue = await dc.getFlexPLMValue(sizeRangeProp, newData, true);
1079
- expect(returnValue).toBeUndefined();
1080
- });
1081
- });
1082
-
1083
- describe('getEntityValue size_range', () => {
1084
- const config: FCConfig = {
1085
- apiHost: 'host',
1086
- userName: () => 'user',
1087
- password: () => 'pass',
1088
- urlContext: 'xxx',
1089
- vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
1090
- csrfEndpoint: '/servlet/rest/security/csrf',
1091
- itemPreDevelopmentLifecycleStages: ['concept']
1092
- };
1093
-
1094
- const mapFileUtil = new MapFileUtil(new Entities());
1095
- const dc = new DataConverter(config, mapFileUtil);
1096
-
1097
- const sizeRangeProp = {
1098
- propertyType: 'size_range',
1099
- slug: 'sizeRange',
1100
- label: 'Size Range',
1101
- };
1102
-
1103
- it('returns sizeRange object when value is present', async () => {
1104
- const data = { sizeRange: { sizes: ['PRE', 'NB'] } };
1105
- const returnValue = await dc.getEntityValue(sizeRangeProp, data);
1106
- expect(returnValue).toEqual({ sizes: ['PRE', 'NB'] });
1107
- });
1108
-
1109
- it('returns null when sizeRange is null', async () => {
1110
- const data = { sizeRange: null };
1111
- const returnValue = await dc.getEntityValue(sizeRangeProp, data);
1112
- expect(returnValue).toBeNull();
1113
- });
1114
-
1115
- it('returns undefined when sizeRange is missing', async () => {
1116
- const data = {};
1117
- const returnValue = await dc.getEntityValue(sizeRangeProp, data);
1118
- expect(returnValue).toBeUndefined();
1119
- });
1120
- });