@contrail/flexplm 1.8.0-alpha.0261c7e → 1.8.0-alpha.562c8dd

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.
@@ -939,14 +939,14 @@ describe('conversion-utils', () => {
939
939
  afterEach(() => {
940
940
  spy.mockRestore();
941
941
  });
942
- it('VibeIQ -> FlexPLM uses defaults', async () => {
942
+ it('should use the defaults when sending a Country from VibeIQ to FlexPLM', async () => {
943
943
  const entity = { entityType: 'custom-entity', typePath: 'custom-entity:country' };
944
944
  expect(await type_conversion_utils_1.TypeConversionUtils.getObjectClass(TRANSFORM_MAP_FILE, mapFileUtil, entity)).toEqual('LCSCountry');
945
945
  expect(await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(TRANSFORM_MAP_FILE, mapFileUtil, entity)).toEqual('Country');
946
946
  expect(await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity)).toEqual(['vibeIQIdentifier']);
947
947
  expect(await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(TRANSFORM_MAP_FILE, mapFileUtil, entity)).toEqual(['name']);
948
948
  });
949
- it('FlexPLM -> VibeIQ uses defaults', async () => {
949
+ it('should use the defaults when receiving a Country from FlexPLM into VibeIQ', async () => {
950
950
  const object = { flexPLMObjectClass: 'LCSCountry', flexPLMTypePath: 'Country' };
951
951
  expect(await type_conversion_utils_1.TypeConversionUtils.getMapKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION)).toEqual('LCSCountry');
952
952
  expect(await type_conversion_utils_1.TypeConversionUtils.getEntityClassFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object)).toEqual('custom-entity');
@@ -954,7 +954,7 @@ describe('conversion-utils', () => {
954
954
  expect(await type_conversion_utils_1.TypeConversionUtils.getIdentifierPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object)).toEqual(['vibeIQIdentifier']);
955
955
  expect(await type_conversion_utils_1.TypeConversionUtils.getInformationalPropertiesFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object)).toEqual(['name']);
956
956
  });
957
- it('a mapping section still overrides the defaults', async () => {
957
+ it('should let a mapping section override the Country defaults', async () => {
958
958
  const overriding = {
959
959
  typeConversion: { vibe2flex: { 'custom-entity': { getMapKey: () => 'LCSCountry' } }, flex2vibe: {} },
960
960
  LCSCountry: { getIdentifierProperties: () => ['isoCode'] }
@@ -987,45 +987,45 @@ describe('conversion-utils', () => {
987
987
  afterEach(() => {
988
988
  spy.mockRestore();
989
989
  });
990
- it("is 'flexplm' when inbound is creatable and outbound is not (both directions)", async () => {
990
+ it('should return flexplm when inbound is creatable and outbound is not, in both directions', async () => {
991
991
  useMap({ isInboundCreatable: () => true, isOutboundCreatable: () => false });
992
992
  expect(await type_conversion_utils_1.TypeConversionUtils.getOriginSystem(TRANSFORM_MAP_FILE, mapFileUtil, countryEntity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION)).toBe('flexplm');
993
993
  expect(await type_conversion_utils_1.TypeConversionUtils.getOriginSystem(TRANSFORM_MAP_FILE, mapFileUtil, countryObject, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION)).toBe('flexplm');
994
994
  });
995
- it("is 'vibeiq' when outbound is creatable and inbound is not (both directions)", async () => {
995
+ it('should return vibeiq when outbound is creatable and inbound is not, in both directions', async () => {
996
996
  useMap({ isInboundCreatable: () => false, isOutboundCreatable: () => true });
997
997
  expect(await type_conversion_utils_1.TypeConversionUtils.getOriginSystem(TRANSFORM_MAP_FILE, mapFileUtil, countryEntity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION)).toBe('vibeiq');
998
998
  expect(await type_conversion_utils_1.TypeConversionUtils.getOriginSystem(TRANSFORM_MAP_FILE, mapFileUtil, countryObject, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION)).toBe('vibeiq');
999
999
  });
1000
- it('supports async mapping functions', async () => {
1000
+ it('should support async mapping functions', async () => {
1001
1001
  useMap({ isInboundCreatable: async () => true, isOutboundCreatable: async () => false });
1002
1002
  expect(await type_conversion_utils_1.TypeConversionUtils.getOriginSystem(TRANSFORM_MAP_FILE, mapFileUtil, countryObject, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION)).toBe('flexplm');
1003
1003
  });
1004
- it('is undefined when both are true', async () => {
1004
+ it('should return undefined when both gates are true', async () => {
1005
1005
  useMap({ isInboundCreatable: () => true, isOutboundCreatable: () => true });
1006
1006
  expect(await type_conversion_utils_1.TypeConversionUtils.getOriginSystem(TRANSFORM_MAP_FILE, mapFileUtil, countryObject, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION)).toBeUndefined();
1007
1007
  });
1008
- it('is undefined when both are false', async () => {
1008
+ it('should return undefined when both gates are false', async () => {
1009
1009
  useMap({ isInboundCreatable: () => false, isOutboundCreatable: () => false });
1010
1010
  expect(await type_conversion_utils_1.TypeConversionUtils.getOriginSystem(TRANSFORM_MAP_FILE, mapFileUtil, countryEntity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION)).toBeUndefined();
1011
1011
  });
1012
- it('is undefined when either function is missing (no defaults)', async () => {
1012
+ it('should return undefined when either gate function is missing', async () => {
1013
1013
  useMap({ isInboundCreatable: () => true });
1014
1014
  expect(await type_conversion_utils_1.TypeConversionUtils.getOriginSystem(TRANSFORM_MAP_FILE, mapFileUtil, countryObject, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION)).toBeUndefined();
1015
1015
  useMap({ isOutboundCreatable: () => true });
1016
1016
  expect(await type_conversion_utils_1.TypeConversionUtils.getOriginSystem(TRANSFORM_MAP_FILE, mapFileUtil, countryEntity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION)).toBeUndefined();
1017
1017
  });
1018
- it('is undefined when there is no LCSCountry section', async () => {
1018
+ it('should return undefined when there is no LCSCountry section', async () => {
1019
1019
  useMap();
1020
1020
  expect(await type_conversion_utils_1.TypeConversionUtils.getOriginSystem(TRANSFORM_MAP_FILE, mapFileUtil, countryEntity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION)).toBeUndefined();
1021
1021
  expect(await type_conversion_utils_1.TypeConversionUtils.getOriginSystem(TRANSFORM_MAP_FILE, mapFileUtil, countryObject, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION)).toBeUndefined();
1022
1022
  });
1023
- it('is undefined when there is no mapping file id or no entity', async () => {
1023
+ it('should return undefined when there is no mapping file id or no entity', async () => {
1024
1024
  useMap({ isInboundCreatable: () => true, isOutboundCreatable: () => false });
1025
1025
  expect(await type_conversion_utils_1.TypeConversionUtils.getOriginSystem('', mapFileUtil, countryObject, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION)).toBeUndefined();
1026
1026
  expect(await type_conversion_utils_1.TypeConversionUtils.getOriginSystem(TRANSFORM_MAP_FILE, mapFileUtil, undefined, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION)).toBeUndefined();
1027
1027
  });
1028
- it('is undefined (and logs) when a mapping function throws', async () => {
1028
+ it('should return undefined and log when a mapping function throws', async () => {
1029
1029
  useMap({ isInboundCreatable: () => { throw new Error('boom'); }, isOutboundCreatable: () => false });
1030
1030
  const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => undefined);
1031
1031
  try {
@@ -1036,12 +1036,12 @@ describe('conversion-utils', () => {
1036
1036
  errorSpy.mockRestore();
1037
1037
  }
1038
1038
  });
1039
- it('does not change the creatable defaults of other types', async () => {
1039
+ it('should not change the section key of other custom entity subtypes', async () => {
1040
1040
  useMap({ isInboundCreatable: () => true, isOutboundCreatable: () => false });
1041
1041
  const other = { entityType: 'custom-entity', typePath: 'custom-entity:exchangeRate' };
1042
1042
  expect(await type_conversion_utils_1.TypeConversionUtils.getMapKey(TRANSFORM_MAP_FILE, mapFileUtil, other, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION)).toEqual('');
1043
1043
  });
1044
- it('finds the Country section even when the org custom-entity routing returns an empty key', async () => {
1044
+ it('should return the LCSCountry section key when the org custom entity routing returns an empty key', async () => {
1045
1045
  useMap({ isInboundCreatable: () => true, isOutboundCreatable: () => false });
1046
1046
  expect(await type_conversion_utils_1.TypeConversionUtils.getMapKey(TRANSFORM_MAP_FILE, mapFileUtil, countryEntity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION)).toEqual('LCSCountry');
1047
1047
  });
@@ -42,7 +42,7 @@ describe('Type Defaults', () => {
42
42
  const objectClass = type_defaults_1.TypeDefaults.getDefaultObjectClass(newData);
43
43
  expect(objectClass).toEqual('LCSColor');
44
44
  });
45
- it('LCSCountry', () => {
45
+ it('should return LCSCountry for a Country custom entity', () => {
46
46
  const newData = {
47
47
  entityType: 'custom-entity',
48
48
  typePath: 'custom-entity:country'
@@ -50,14 +50,14 @@ describe('Type Defaults', () => {
50
50
  const objectClass = type_defaults_1.TypeDefaults.getDefaultObjectClass(newData);
51
51
  expect(objectClass).toEqual('LCSCountry');
52
52
  });
53
- it('LCSCountry - typePath is case-insensitive', () => {
53
+ it('should return LCSCountry when the Country typePath uses different casing', () => {
54
54
  const newData = {
55
55
  entityType: 'custom-entity',
56
56
  typePath: 'custom-entity:Country'
57
57
  };
58
58
  expect(type_defaults_1.TypeDefaults.getDefaultObjectClass(newData)).toEqual('LCSCountry');
59
59
  });
60
- it('other custom-entity subtype is still LCSRevisableEntity', () => {
60
+ it('should return LCSRevisableEntity for a custom entity that is not a Country', () => {
61
61
  const newData = {
62
62
  entityType: 'custom-entity',
63
63
  typePath: 'custom-entity:exchangeRate'
@@ -142,14 +142,14 @@ describe('Type Defaults', () => {
142
142
  const typePath = type_defaults_1.TypeDefaults.getDefaultObjectTypePath(newData);
143
143
  expect(typePath).toEqual('Color');
144
144
  });
145
- it('custom-entity - country', () => {
145
+ it('should return Country as the FlexPLM type path for a Country custom entity', () => {
146
146
  const newData = {
147
147
  entityType: 'custom-entity',
148
148
  typePath: 'custom-entity:country'
149
149
  };
150
150
  expect(type_defaults_1.TypeDefaults.getDefaultObjectTypePath(newData)).toEqual('Country');
151
151
  });
152
- it('custom-entity - other subtype stays Revisable Entity', () => {
152
+ it('should return Revisable Entity as the type path for a custom entity that is not a Country', () => {
153
153
  const newData = {
154
154
  entityType: 'custom-entity',
155
155
  typePath: 'custom-entity:exchangeRate'
@@ -255,7 +255,7 @@ describe('Type Defaults', () => {
255
255
  expect(defaultIdentifiers).toContain('name');
256
256
  expect(defaultIdentifiers).toHaveLength(1);
257
257
  });
258
- it('custom-entity - country', () => {
258
+ it('should return vibeIQIdentifier as the identifier for a Country custom entity', () => {
259
259
  const newData = {
260
260
  entityType: 'custom-entity',
261
261
  typePath: 'custom-entity:country'
@@ -263,7 +263,7 @@ describe('Type Defaults', () => {
263
263
  const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierProperties(newData);
264
264
  expect(defaultIdentifiers).toEqual(['vibeIQIdentifier']);
265
265
  });
266
- it('custom-entity - other subtype stays name', () => {
266
+ it('should return name as the identifier for a custom entity that is not a Country', () => {
267
267
  const newData = {
268
268
  entityType: 'custom-entity',
269
269
  typePath: 'custom-entity:exchangeRate'
@@ -321,14 +321,14 @@ describe('Type Defaults', () => {
321
321
  const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultInformationalProperties(newData);
322
322
  expect(defaultIdentifiers).toHaveLength(0);
323
323
  });
324
- it('custom-entity - country', () => {
324
+ it('should return name as the informational property for a Country custom entity', () => {
325
325
  const newData = {
326
326
  entityType: 'custom-entity',
327
327
  typePath: 'custom-entity:country'
328
328
  };
329
329
  expect(type_defaults_1.TypeDefaults.getDefaultInformationalProperties(newData)).toEqual(['name']);
330
330
  });
331
- it('custom-entity - other subtype has none', () => {
331
+ it('should return no informational properties for a custom entity that is not a Country', () => {
332
332
  const newData = {
333
333
  entityType: 'custom-entity',
334
334
  typePath: 'custom-entity:exchangeRate'
@@ -344,10 +344,10 @@ describe('Type Defaults', () => {
344
344
  });
345
345
  });
346
346
  describe('isCountryEntity', () => {
347
- it('true for custom-entity:country', () => {
347
+ it('should return true for the custom-entity:country type path', () => {
348
348
  expect(type_defaults_1.TypeDefaults.isCountryEntity({ typePath: 'custom-entity:country' })).toBe(true);
349
349
  });
350
- it('false for another subtype, a missing typePath, or undefined', () => {
350
+ it('should return false for another subtype, a missing typePath, or an undefined entity', () => {
351
351
  expect(type_defaults_1.TypeDefaults.isCountryEntity({ typePath: 'custom-entity:other' })).toBe(false);
352
352
  expect(type_defaults_1.TypeDefaults.isCountryEntity({})).toBe(false);
353
353
  expect(type_defaults_1.TypeDefaults.isCountryEntity(undefined)).toBe(false);
@@ -430,13 +430,13 @@ describe('Type Defaults', () => {
430
430
  const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
431
431
  expect(entityClass).toBe('assortment');
432
432
  });
433
- it('custom-entity - LCSCountry', () => {
433
+ it('should return custom-entity as the entity class for LCSCountry', () => {
434
434
  const object = {
435
435
  flexPLMObjectClass: 'LCSCountry'
436
436
  };
437
437
  expect(type_defaults_1.TypeDefaults.getDefaultEntityClass(object)).toBe('custom-entity');
438
438
  });
439
- it('custom-entity - LCSCountry - processAsItem=true', () => {
439
+ it('should return custom-entity for LCSCountry when LCSMaterial processAsItem is true', () => {
440
440
  const object = {
441
441
  flexPLMObjectClass: 'LCSCountry'
442
442
  };
@@ -512,7 +512,7 @@ describe('Type Defaults', () => {
512
512
  const typePath = type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
513
513
  expect(typePath).toBe('project-item');
514
514
  });
515
- it('LCSCountry', () => {
515
+ it('should return custom-entity:country as the VibeIQ type path for LCSCountry', () => {
516
516
  const object = {
517
517
  flexPLMObjectClass: 'LCSCountry'
518
518
  };
@@ -600,7 +600,7 @@ describe('Type Defaults', () => {
600
600
  expect(defaultIdentifiers).toContain('name');
601
601
  expect(defaultIdentifiers).toHaveLength(1);
602
602
  });
603
- it('LCSCountry', () => {
603
+ it('should return vibeIQIdentifier as the identifier for an LCSCountry object', () => {
604
604
  const object = {
605
605
  flexPLMObjectClass: 'LCSCountry'
606
606
  };
@@ -646,7 +646,7 @@ describe('Type Defaults', () => {
646
646
  });
647
647
  }); //getDefaultIdentifierPropertiesFromObject
648
648
  describe('getDefaultInformationalPropertiesFromObject', () => {
649
- it('LCSCountry', () => {
649
+ it('should return name as the informational property for an LCSCountry object', () => {
650
650
  const object = {
651
651
  flexPLMObjectClass: 'LCSCountry'
652
652
  };
@@ -47,6 +47,31 @@ describe('TypeUtils.getEventObjectClass() tests', () => {
47
47
  const objectClass = tu.getEventObjectClass(entityType, newData);
48
48
  expect(objectClass).toEqual('LCSRevisableEntity');
49
49
  });
50
+ it('should return LCSCountry for a custom entity with the custom-entity:country typePath', () => {
51
+ const entityType = 'custom-entity';
52
+ const newData = { typePath: 'custom-entity:country' };
53
+ const objectClass = tu.getEventObjectClass(entityType, newData);
54
+ expect(objectClass).toEqual('LCSCountry');
55
+ });
56
+ it('should return LCSCountry when the Country typePath uses different casing', () => {
57
+ const objectClass = tu.getEventObjectClass('custom-entity', { typePath: 'custom-entity:Country' });
58
+ expect(objectClass).toEqual('LCSCountry');
59
+ });
60
+ it('should return LCSRevisableEntity for a custom entity that is not a Country', () => {
61
+ const objectClass = tu.getEventObjectClass('custom-entity', { typePath: 'custom-entity:exchangeRate' });
62
+ expect(objectClass).toEqual('LCSRevisableEntity');
63
+ });
64
+ });
65
+ describe('TypeUtils.getEntityTypeClientOptions() tests', () => {
66
+ const tu = new type_utils_1.TypeUtils();
67
+ it('should resolve LCSCountry to the custom-entity root type', () => {
68
+ const options = tu.getEntityTypeClientOptions('LCSCountry', {});
69
+ expect(options).toEqual({ root: 'custom-entity' });
70
+ });
71
+ it('should keep resolving LCSRevisableEntity to the custom-entity root type', () => {
72
+ const options = tu.getEntityTypeClientOptions('LCSRevisableEntity', {});
73
+ expect(options).toEqual({ root: 'custom-entity' });
74
+ });
50
75
  });
51
76
  describe('filterProperties-item', () => {
52
77
  const itemType = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.8.0-alpha.0261c7e",
3
+ "version": "1.8.0-alpha.562c8dd",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",