dyo-tools 0.2.0 → 0.3.0

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 (167) hide show
  1. package/dist/constants.js +4 -4
  2. package/dist/constants.js.map +1 -1
  3. package/dist/core/DTAction.d.ts +10 -0
  4. package/dist/core/DTAction.js +24 -0
  5. package/dist/core/DTAction.js.map +1 -0
  6. package/dist/core/DTBunch.d.ts +6 -7
  7. package/dist/core/DTBunch.js +16 -13
  8. package/dist/core/DTBunch.js.map +1 -1
  9. package/dist/core/DTComponentPhysical.d.ts +6 -4
  10. package/dist/core/DTComponentPhysical.js +6 -0
  11. package/dist/core/DTComponentPhysical.js.map +1 -1
  12. package/dist/core/DTElement.d.ts +5 -0
  13. package/dist/core/DTElement.js +12 -2
  14. package/dist/core/DTElement.js.map +1 -1
  15. package/dist/core/DTManager.d.ts +3 -1
  16. package/dist/core/DTManager.js +24 -14
  17. package/dist/core/DTManager.js.map +1 -1
  18. package/dist/core/DTMaster.d.ts +24 -0
  19. package/dist/core/DTMaster.js +133 -0
  20. package/dist/core/DTMaster.js.map +1 -0
  21. package/dist/core/DTModule.d.ts +14 -0
  22. package/dist/core/DTModule.js +39 -0
  23. package/dist/core/DTModule.js.map +1 -0
  24. package/dist/index.d.ts +5 -1
  25. package/dist/index.js +11 -3
  26. package/dist/index.js.map +1 -1
  27. package/dist/libs/player/DTPlayer.element.d.ts +5 -0
  28. package/dist/libs/player/DTPlayer.element.js +11 -0
  29. package/dist/libs/player/DTPlayer.element.js.map +1 -0
  30. package/dist/libs/player/DTPlayer.manager.d.ts +11 -0
  31. package/dist/libs/player/DTPlayer.manager.js +42 -0
  32. package/dist/libs/player/DTPlayer.manager.js.map +1 -0
  33. package/dist/tsconfig.tsbuildinfo +1 -1
  34. package/dist/types/core.d.ts +103 -0
  35. package/dist/types/core.js +15 -0
  36. package/dist/types/core.js.map +1 -0
  37. package/dist/types/index.d.ts +2 -98
  38. package/dist/types/index.js +16 -12
  39. package/dist/types/index.js.map +1 -1
  40. package/dist/types/player.d.ts +5 -0
  41. package/dist/types/player.js +3 -0
  42. package/dist/types/player.js.map +1 -0
  43. package/docs/assets/highlight.css +29 -29
  44. package/docs/assets/main.js +59 -58
  45. package/docs/assets/navigation.js +1 -0
  46. package/docs/assets/search.js +1 -1
  47. package/docs/assets/style.css +1414 -1367
  48. package/docs/classes/core_DTAction.DYOToolsAction.html +89 -0
  49. package/docs/classes/core_DTBunch.DYOToolsBunch.html +254 -0
  50. package/docs/classes/core_DTComponent.DYOToolsComponent.html +76 -0
  51. package/docs/classes/core_DTComponentPhysical.DYOToolsComponentPhysical.html +110 -0
  52. package/docs/classes/core_DTComponentWithMeta.DYOToolsComponentWithMeta.html +96 -0
  53. package/docs/classes/core_DTElement.DYOToolsElement.html +135 -0
  54. package/docs/classes/core_DTError.DYOToolsError.html +37 -0
  55. package/docs/classes/core_DTManager.DYOToolsManager.html +237 -0
  56. package/docs/classes/core_DTMaster.DYOToolsMaster.html +150 -0
  57. package/docs/classes/core_DTModule.DYOToolsModule.html +92 -0
  58. package/docs/classes/libs_DYOFinder.DYOFinder.html +34 -0
  59. package/docs/classes/libs_player_DTPlayer_element.DYOToolsPlayer.html +134 -0
  60. package/docs/classes/libs_player_DTPlayer_manager.DYOToolsPlayerManager.html +243 -0
  61. package/docs/enums/types_core.FilterOperatorType.html +10 -0
  62. package/docs/hierarchy.html +1 -0
  63. package/docs/index.html +1 -46
  64. package/docs/interfaces/types_core.DTBunchFilters.html +6 -0
  65. package/docs/interfaces/types_core.DTBunchOptions.html +19 -0
  66. package/docs/interfaces/types_core.DTBunchToObject.html +7 -0
  67. package/docs/interfaces/types_core.DTComponentOptions.html +5 -0
  68. package/docs/interfaces/types_core.DTComponentToObject.html +4 -0
  69. package/docs/interfaces/types_core.DTElementToObject.html +7 -0
  70. package/docs/interfaces/types_core.DTManagerFilters.html +6 -0
  71. package/docs/interfaces/types_core.DTManagerOptions.html +8 -0
  72. package/docs/interfaces/types_core.DTManagerToObject.html +5 -0
  73. package/docs/interfaces/types_core.DTMasterToObject.html +8 -0
  74. package/docs/interfaces/types_core.DTModuleToObject.html +6 -0
  75. package/docs/interfaces/types_core.DYOFinderConfigurationPropDefault.html +4 -0
  76. package/docs/interfaces/types_core.DYOFinderConfigurationPropObjectSearch.html +4 -0
  77. package/docs/interfaces/types_core.DYOFinderFilterOperatorAdvanced.html +5 -0
  78. package/docs/interfaces/types_core.DYOFinderFilterOperatorBase.html +5 -0
  79. package/docs/interfaces/types_player.DTPlayerManagerSimpleConfiguration.html +3 -0
  80. package/docs/modules/constants.html +6 -0
  81. package/docs/modules/core_DTAction.html +2 -0
  82. package/docs/modules/core_DTBunch.html +2 -0
  83. package/docs/modules/core_DTComponent.html +2 -0
  84. package/docs/modules/core_DTComponentPhysical.html +2 -0
  85. package/docs/modules/core_DTComponentWithMeta.html +2 -0
  86. package/docs/modules/core_DTElement.html +2 -0
  87. package/docs/modules/core_DTError.html +2 -0
  88. package/docs/modules/core_DTManager.html +2 -0
  89. package/docs/modules/core_DTMaster.html +2 -0
  90. package/docs/modules/core_DTModule.html +2 -0
  91. package/docs/modules/libs_DYOFinder.html +2 -0
  92. package/docs/modules/libs_player_DTPlayer_element.html +2 -0
  93. package/docs/modules/libs_player_DTPlayer_manager.html +2 -0
  94. package/docs/modules/types.html +29 -0
  95. package/docs/modules/types_core.html +28 -0
  96. package/docs/modules/types_player.html +2 -0
  97. package/docs/types/types_core.DTAcceptedMetaData.html +2 -0
  98. package/docs/types/types_core.DTManagerItemType.html +1 -0
  99. package/docs/types/types_core.DTManagerItemsType.html +2 -0
  100. package/docs/types/types_core.DYOFinderComponentType.html +1 -0
  101. package/docs/types/types_core.DYOFinderConfiguration.html +2 -0
  102. package/docs/types/types_core.DYOFinderConfigurationProp.html +1 -0
  103. package/docs/types/types_core.DYOFinderFilterOperator.html +1 -0
  104. package/docs/types/types_core.DYOFinderFilterOperatorArgument.html +1 -0
  105. package/docs/types/types_core.DYOFinderFilters.html +1 -0
  106. package/docs/types/types_core.StandardPrimitiveType.html +2 -0
  107. package/docs/types/types_core.StandardPrimitiveTypeWithArray.html +1 -0
  108. package/docs/variables/constants.bunchDefaultOptions.html +2 -0
  109. package/docs/variables/constants.componentBunchDefaultFinderConfiguration.html +1 -0
  110. package/docs/variables/constants.componentManagerDefaultFinderConfiguration.html +1 -0
  111. package/docs/variables/constants.componentPhysicalDefaultFinderConfiguration.html +1 -0
  112. package/docs/variables/constants.managerDefaultOptions.html +2 -0
  113. package/package.json +16 -17
  114. package/src/constants.ts +85 -85
  115. package/src/core/DTAction.ts +52 -0
  116. package/src/core/DTBunch.ts +467 -461
  117. package/src/core/DTComponent.ts +225 -225
  118. package/src/core/DTComponentPhysical.ts +53 -39
  119. package/src/core/DTComponentWithMeta.ts +65 -65
  120. package/src/core/DTElement.ts +102 -69
  121. package/src/core/DTError.ts +78 -78
  122. package/src/core/DTManager.ts +465 -446
  123. package/src/core/DTMaster.ts +318 -0
  124. package/src/core/DTModule.ts +90 -0
  125. package/src/index.ts +17 -9
  126. package/src/libs/DYOFinder.ts +175 -175
  127. package/src/libs/player/DTPlayer.element.ts +9 -0
  128. package/src/libs/player/DTPlayer.manager.ts +84 -0
  129. package/src/types/core.ts +169 -0
  130. package/src/types/index.ts +2 -162
  131. package/src/types/player.ts +6 -0
  132. package/test/core/DTAction.double.ts +78 -0
  133. package/test/core/DTAction.spec.ts +76 -0
  134. package/test/core/DTBunch.double.ts +18 -10
  135. package/test/core/DTBunch.spec.ts +70 -68
  136. package/test/core/DTComponentPhysical.double.ts +3 -3
  137. package/test/core/DTComponentPhysical.spec.ts +25 -11
  138. package/test/core/DTElement.double.ts +21 -5
  139. package/test/core/DTElement.spec.ts +52 -8
  140. package/test/core/DTError.double.ts +1 -1
  141. package/test/core/DTManager.double.ts +29 -5
  142. package/test/core/DTManager.spec.ts +80 -17
  143. package/test/core/DTMaster.double.ts +141 -0
  144. package/test/core/DTMaster.spec.ts +584 -0
  145. package/test/core/DTModule.double.ts +80 -0
  146. package/test/core/DTModule.spec.ts +138 -0
  147. package/test/core/copy.spec.ts +20 -4
  148. package/test/{core/DTPlayer.double.ts → libs/player/DTPlayer.element.double.ts} +15 -24
  149. package/test/libs/player/DTPlayer.element.spec.ts +28 -0
  150. package/test/libs/player/DTPlayer.manager.double.ts +92 -0
  151. package/test/libs/player/DTPlayer.manager.spec.ts +178 -0
  152. package/LICENSE +0 -21
  153. package/cucumber.js +0 -9
  154. package/dist/core/DTPlayer.d.ts +0 -8
  155. package/dist/core/DTPlayer.js +0 -30
  156. package/dist/core/DTPlayer.js.map +0 -1
  157. package/e2e/0.2.0/epic1.feature +0 -29
  158. package/e2e/0.2.0/epic2.feature +0 -22
  159. package/e2e/0.2.0/epic3.feature +0 -25
  160. package/e2e/0.2.0/resources/dominion.js +0 -195
  161. package/e2e/0.2.0/resources/utils.js +0 -27
  162. package/e2e/0.2.0/support/steps.js +0 -108
  163. package/e2e/future/epic4.feature +0 -39
  164. package/e2e/future/resources/dominion.js +0 -238
  165. package/e2e/future/resources/utils.js +0 -27
  166. package/src/core/DTPlayer.ts +0 -57
  167. package/test/core/DTPlayer.spec.ts +0 -80
@@ -24,17 +24,10 @@ import { DTBunch, DTComponentPhysical } from '../../src';
24
24
  import DYOToolsElement from '../../src/core/DTElement';
25
25
  import { BunchMetaData, HaileiMetaData, IMetaDataTest } from './DTComponentWithMeta.double';
26
26
  import { DTBunchOptions, FilterOperatorType } from '../../src/types';
27
- import {
28
- DTPlayerStub,
29
- IDTest as IDTestPlayer,
30
- IDTest as IDPlayerTest,
31
- KeyTest as KeyPlayerTest,
32
- toStringTest as toStringPlayerTest,
33
- } from './DTPlayer.double';
34
27
  import { checkCallForMockedDTError, CodeTest as DTErrorCodeTest, DTErrorStub } from './DTError.double';
35
28
  import DYOToolsError from '../../src/core/DTError';
36
- import { mockOverriddenMethods } from './DTComponentPhysical.double';
37
- import { DTManagerStub } from './DTManager.double';
29
+ import { mockOverriddenMethods, OwnerTest } from './DTComponentPhysical.double';
30
+ import { DTManagerStub, IDTest as managerIDTest } from './DTManager.double';
38
31
  import { componentBunchDefaultFinderConfiguration } from '../../src/constants';
39
32
  import Mocked = jest.Mocked;
40
33
  import MockedFunction = jest.MockedFunction;
@@ -124,7 +117,7 @@ describe('class DYOToolsBunch', () => {
124
117
  uniqueKey: true,
125
118
  inheritOwner: true,
126
119
  replaceIndex: false,
127
- virtualContext: false,
120
+ virtualContainer: false,
128
121
  });
129
122
  expect(newBunch.th_get_items()).toStrictEqual([]);
130
123
  });
@@ -174,42 +167,42 @@ describe('class DYOToolsBunch', () => {
174
167
  const finderConfigurationToCheck = bunchTest.getFinderConfiguration().owner;
175
168
 
176
169
  expect(finderConfigurationToCheck.operators).toStrictEqual(baseOperators);
177
- expect(finderConfigurationToCheck.getValue(element)).toBeNull();
170
+ expect(finderConfigurationToCheck.getValue(element)).toBeUndefined();
178
171
  expect(finderConfigurationToCheck.objectSearch).toBe(false);
179
172
  });
180
173
 
181
174
  test('check finder configuration for owner attribute - with owner', () => {
182
175
  const element = new DTElementStub();
183
- jest.spyOn(element, 'getOwner').mockImplementation(() => new DTPlayerStub());
176
+ jest.spyOn(element, 'getOwner').mockReturnValue(OwnerTest);
184
177
 
185
178
  const finderConfigurationToCheck = bunchTest.getFinderConfiguration().owner;
186
179
 
187
180
  expect(finderConfigurationToCheck.operators).toStrictEqual(baseOperators);
188
- expect(finderConfigurationToCheck.getValue(element)).toBe(IDTestPlayer);
181
+ expect(finderConfigurationToCheck.getValue(element)).toBe(OwnerTest);
189
182
  expect(finderConfigurationToCheck.objectSearch).toBe(false);
190
183
  });
191
184
 
192
- test('check finder configuration for context attribute - empty context', () => {
185
+ test('check finder configuration for container attribute - empty container', () => {
193
186
  const element = new DTElementStub();
194
- jest.spyOn(element, 'getContext').mockImplementation(() => undefined);
187
+ jest.spyOn(element, 'getContainer').mockImplementation(() => undefined);
195
188
 
196
- const finderConfigurationToCheck = bunchTest.getFinderConfiguration().context;
189
+ const finderConfigurationToCheck = bunchTest.getFinderConfiguration().container;
197
190
 
198
191
  expect(finderConfigurationToCheck.operators).toStrictEqual(baseOperators);
199
192
  expect(finderConfigurationToCheck.getValue(element)).toBeNull();
200
193
  expect(finderConfigurationToCheck.objectSearch).toBe(false);
201
194
  });
202
195
 
203
- test('check finder configuration for context attribute - with context', () => {
196
+ test('check finder configuration for container attribute - with container', () => {
204
197
  const element = new DTElementStub();
205
198
  const bunch = new DTBunchStub();
206
- jest.spyOn(bunch, 'getId').mockImplementation(() => `${IDTest}_other_context`);
207
- jest.spyOn(element, 'getContext').mockImplementation(() => bunch);
199
+ jest.spyOn(bunch, 'getId').mockImplementation(() => `${IDTest}_other_container`);
200
+ jest.spyOn(element, 'getContainer').mockImplementation(() => bunch);
208
201
 
209
- const finderConfigurationToCheck = bunchTest.getFinderConfiguration().context;
202
+ const finderConfigurationToCheck = bunchTest.getFinderConfiguration().container;
210
203
 
211
204
  expect(finderConfigurationToCheck.operators).toStrictEqual(baseOperators);
212
- expect(finderConfigurationToCheck.getValue(element)).toBe(`${IDTest}_other_context`);
205
+ expect(finderConfigurationToCheck.getValue(element)).toBe(`${IDTest}_other_container`);
213
206
  expect(finderConfigurationToCheck.objectSearch).toBe(false);
214
207
  });
215
208
 
@@ -227,15 +220,14 @@ describe('class DYOToolsBunch', () => {
227
220
 
228
221
  describe('setOwner()', () => {
229
222
  beforeEach(() => {
230
- jest.spyOn(bunchTest, 'getOwner').mockImplementation(() => new DTPlayerStub());
223
+ jest.spyOn(bunchTest, 'getOwner').mockReturnValue(OwnerTest);
231
224
  });
232
225
 
233
226
  test('add a new owner - not updating elements owner when inheritOwner = false', () => {
234
227
  bunchTest.th_set_options({ inheritOwner: false });
235
228
  bunchTest.th_set_items(generateMockedElements(3));
236
229
 
237
- const owner = new DTPlayerStub();
238
- bunchTest.setOwner(owner);
230
+ bunchTest.setOwner(OwnerTest);
239
231
 
240
232
  expect(bunchTest.th_get_items()[0].setOwner.mock.calls.length).toBe(0);
241
233
  expect(bunchTest.th_get_items()[1].setOwner.mock.calls.length).toBe(0);
@@ -246,15 +238,14 @@ describe('class DYOToolsBunch', () => {
246
238
  bunchTest.th_set_options({ inheritOwner: true });
247
239
  bunchTest.th_set_items(generateMockedElements(3));
248
240
 
249
- const owner = new DTPlayerStub();
250
- bunchTest.setOwner(owner);
241
+ bunchTest.setOwner(OwnerTest);
251
242
 
252
243
  expect(bunchTest.th_get_items()[0].setOwner.mock.calls.length).toBe(1);
253
- expect(bunchTest.th_get_items()[0].setOwner.mock.calls[0][0].getId()).toBe(IDPlayerTest);
244
+ expect(bunchTest.th_get_items()[0].setOwner.mock.calls[0][0]).toBe(OwnerTest);
254
245
  expect(bunchTest.th_get_items()[1].setOwner.mock.calls.length).toBe(1);
255
- expect(bunchTest.th_get_items()[1].setOwner.mock.calls[0][0].getId()).toBe(IDPlayerTest);
246
+ expect(bunchTest.th_get_items()[1].setOwner.mock.calls[0][0]).toBe(OwnerTest);
256
247
  expect(bunchTest.th_get_items()[2].setOwner.mock.calls.length).toBe(1);
257
- expect(bunchTest.th_get_items()[2].setOwner.mock.calls[0][0].getId()).toBe(IDPlayerTest);
248
+ expect(bunchTest.th_get_items()[2].setOwner.mock.calls[0][0]).toBe(OwnerTest);
258
249
  });
259
250
  });
260
251
 
@@ -340,7 +331,6 @@ describe('class DYOToolsBunch', () => {
340
331
  });
341
332
  });
342
333
 
343
- // TODO : Add test cases for updating Library from manager
344
334
  describe('addAtIndex()', () => {
345
335
  let objectToAdd;
346
336
  let objectsToAdd;
@@ -436,68 +426,82 @@ describe('class DYOToolsBunch', () => {
436
426
  });
437
427
 
438
428
  test('not inherit owner when adding an item - default case', () => {
439
- const owner = new DTPlayerStub();
440
- bunchTest.th_set_owner(owner);
429
+ bunchTest.th_set_owner(OwnerTest);
441
430
 
442
431
  bunchTest.addAtIndex(objectToAdd, 2);
443
432
 
444
- expect(bunchTest.th_get_owner().getId()).toBe(IDPlayerTest);
433
+ expect(bunchTest.th_get_owner()).toBe(OwnerTest);
445
434
  expect(objectToAdd.setOwner.mock.calls.length).toBe(0);
446
435
  });
447
436
 
448
437
  test('inherit owner when adding an item - inheritOwner option', () => {
449
- const owner = new DTPlayerStub();
450
- bunchTest.th_set_owner(owner);
438
+ bunchTest.th_set_owner(OwnerTest);
451
439
 
452
440
  bunchTest.addAtIndex(objectToAdd, 2, { inheritOwner: true });
453
441
 
454
- expect(bunchTest.th_get_owner().getId()).toBe(IDPlayerTest);
442
+ expect(bunchTest.th_get_owner()).toBe(OwnerTest);
455
443
  expect(objectToAdd.setOwner.mock.calls.length).toBe(1);
456
- expect(objectToAdd.setOwner.mock.calls[0][0].getId()).toBe(IDPlayerTest);
444
+ expect(objectToAdd.setOwner.mock.calls[0][0]).toBe(OwnerTest);
445
+ });
446
+
447
+ test('not set context if undefined when adding an item', () => {
448
+ bunchTest.addAtIndex(objectToAdd, 2);
449
+
450
+ expect(bunchTest.th_get_items()[2].setContext.mock.calls.length).toBe(0);
457
451
  });
458
452
 
459
- test('set context when adding an item - default case', () => {
453
+ test('set context with parent manager when adding an item', () => {
454
+ const manager = new DTManagerStub();
455
+ bunchTest.th_set_context(manager);
456
+
460
457
  bunchTest.addAtIndex(objectToAdd, 2);
461
458
 
462
459
  expect(bunchTest.th_get_items()[2].setContext.mock.calls.length).toBe(1);
463
- expect(bunchTest.th_get_items()[2].setContext.mock.calls[0][0].getId()).toBe(IDTest);
460
+ expect(bunchTest.th_get_items()[2].setContext.mock.calls[0][0].getId()).toBe(managerIDTest);
464
461
  });
465
462
 
466
- test('not set context when adding an item - virtualContext option', () => {
467
- bunchTest.th_set_options({ virtualContext: true });
463
+ test('set container when adding an item', () => {
464
+ bunchTest.addAtIndex(objectToAdd, 2);
465
+
466
+ expect(bunchTest.th_get_items()[2].setContainer.mock.calls.length).toBe(1);
467
+ expect(bunchTest.th_get_items()[2].setContainer.mock.calls[0][0].getId()).toBe(IDTest);
468
+ });
469
+
470
+ test('not set container when adding an item - virtualContainer option', () => {
471
+ bunchTest.th_set_options({ virtualContainer: true });
468
472
 
469
473
  bunchTest.addAtIndex(objectToAdd, 2);
470
474
 
471
- expect(bunchTest.th_get_items()[2].setContext.mock.calls.length).toBe(0);
475
+ expect(bunchTest.th_get_items()[2].setContainer.mock.calls.length).toBe(0);
472
476
  });
473
477
 
474
- test('set context when adding an item - remove from old bunch', () => {
478
+ test('set container when adding an item - remove from old bunch', () => {
475
479
  const bunchTestOld = new DTBunchTest();
476
480
  bunchTestOld.th_set_items(generateMockedElements(6));
477
481
  objectToAdd = bunchTestOld.th_get_items()[5];
478
- objectToAdd.setContext(bunchTestOld);
479
- objectToAdd.setContext.mockClear();
482
+ objectToAdd.setContainer(bunchTestOld);
483
+ objectToAdd.setContainer.mockClear();
480
484
  jest.spyOn(bunchTestOld, 'remove').mockImplementation(() => {});
481
485
  jest.spyOn(bunchTestOld, 'getComponentType').mockImplementation(() => 'bunch');
482
486
 
483
487
  bunchTest.addAtIndex(objectToAdd, 2);
484
488
 
485
- expect(bunchTest.th_get_items()[2].setContext.mock.calls.length).toBe(1);
486
- expect(bunchTest.th_get_items()[2].setContext.mock.calls[0][0].getId()).toBe(IDTest);
489
+ expect(bunchTest.th_get_items()[2].setContainer.mock.calls.length).toBe(1);
490
+ expect(bunchTest.th_get_items()[2].setContainer.mock.calls[0][0].getId()).toBe(IDTest);
487
491
  expect((bunchTestOld.remove as any).mock.calls.length).toBe(1);
488
492
  expect((bunchTestOld.remove as any).mock.calls[0][0]).toBe(objectToAdd.getId());
489
493
  });
490
494
 
491
- test('set context when adding an item - dont remove if virtualContext option', () => {
495
+ test('set container when adding an item - dont remove if virtualContainer option', () => {
492
496
  const bunchTestOld = new DTBunchTest();
493
497
  bunchTestOld.th_set_items(generateMockedElements(6));
494
498
  objectToAdd = bunchTestOld.th_get_items()[5];
495
499
  jest.spyOn(bunchTestOld, 'remove').mockImplementation(() => {});
496
500
 
497
- bunchTest.th_set_options({ virtualContext: true });
501
+ bunchTest.th_set_options({ virtualContainer: true });
498
502
  bunchTest.addAtIndex(objectToAdd, 2);
499
503
 
500
- expect(bunchTest.th_get_items()[2].setContext.mock.calls.length).toBe(0);
504
+ expect(bunchTest.th_get_items()[2].setContainer.mock.calls.length).toBe(0);
501
505
  expect((bunchTestOld.remove as any).mock.calls.length).toBe(0);
502
506
  });
503
507
 
@@ -683,8 +687,6 @@ describe('class DYOToolsBunch', () => {
683
687
  };
684
688
 
685
689
  beforeEach(() => {
686
- jest.spyOn(bunchTest, 'removeContext').mockImplementation(() => {});
687
-
688
690
  bunchTest.th_set_items(generateMockedElements(5));
689
691
  });
690
692
 
@@ -718,7 +720,7 @@ describe('class DYOToolsBunch', () => {
718
720
  checkAllItemsInBunch(bunchTest, 2);
719
721
  });
720
722
 
721
- test('define context at undefined for removed items - default case', () => {
723
+ test('define container at undefined for removed items - default case', () => {
722
724
  const items = [
723
725
  bunchTest.th_get_items()[1],
724
726
  bunchTest.th_get_items()[2],
@@ -729,27 +731,27 @@ describe('class DYOToolsBunch', () => {
729
731
  items.push(bunchTest.th_get_items()[1]);
730
732
  bunchTest.removeMany([0, 1]);
731
733
 
732
- expect(items[0].removeContext.mock.calls.length).toBe(1);
733
- expect(items[1].removeContext.mock.calls.length).toBe(1);
734
- expect(items[2].removeContext.mock.calls.length).toBe(1);
735
- expect(items[3].removeContext.mock.calls.length).toBe(1);
734
+ expect(items[0].removeContainer.mock.calls.length).toBe(1);
735
+ expect(items[1].removeContainer.mock.calls.length).toBe(1);
736
+ expect(items[2].removeContainer.mock.calls.length).toBe(1);
737
+ expect(items[3].removeContainer.mock.calls.length).toBe(1);
736
738
  });
737
739
 
738
- test('not change context for removed items - virtual context option', () => {
740
+ test('not change container for removed items - virtual container option', () => {
739
741
  const items = [
740
742
  bunchTest.th_get_items()[1],
741
743
  bunchTest.th_get_items()[2],
742
744
  ];
743
- bunchTest.th_set_options({ virtualContext: true });
745
+ bunchTest.th_set_options({ virtualContainer: true });
744
746
  bunchTest.removeMany([`${MeldrineIdTest}-1`, `${MaydenaIdTest}-2`]);
745
747
  items.push(bunchTest.th_get_items()[0]);
746
748
  items.push(bunchTest.th_get_items()[1]);
747
749
  bunchTest.removeMany([0, 1]);
748
750
 
749
- expect(items[0].removeContext.mock.calls.length).toBe(0);
750
- expect(items[1].removeContext.mock.calls.length).toBe(0);
751
- expect(items[2].removeContext.mock.calls.length).toBe(0);
752
- expect(items[3].removeContext.mock.calls.length).toBe(0);
751
+ expect(items[0].removeContainer.mock.calls.length).toBe(0);
752
+ expect(items[1].removeContainer.mock.calls.length).toBe(0);
753
+ expect(items[2].removeContainer.mock.calls.length).toBe(0);
754
+ expect(items[3].removeContainer.mock.calls.length).toBe(0);
753
755
  });
754
756
  });
755
757
 
@@ -830,11 +832,11 @@ describe('class DYOToolsBunch', () => {
830
832
  });
831
833
 
832
834
  test('toObject output standard with owner', () => {
833
- bunchTest.th_set_owner(new DTPlayerStub());
835
+ bunchTest.th_set_owner(OwnerTest);
834
836
 
835
837
  const toObjectBunch = bunchTest.toObject();
836
838
  expect(Object.keys(toObjectBunch)).toStrictEqual(['id', 'key', 'type', 'items', 'owner']);
837
- expect(toObjectBunch.owner.toString()).toBe(toStringPlayerTest);
839
+ expect(toObjectBunch.owner).toBe(OwnerTest);
838
840
  });
839
841
 
840
842
  test('toObject output standard with owner and meta', () => {
@@ -842,7 +844,7 @@ describe('class DYOToolsBunch', () => {
842
844
  return this._meta;
843
845
  });
844
846
 
845
- bunchTest.th_set_owner(new DTPlayerStub());
847
+ bunchTest.th_set_owner(OwnerTest);
846
848
  bunchTest.th_set_meta(BunchMetaData);
847
849
 
848
850
  const toObjectBunch = bunchTest.toObject();
@@ -886,10 +888,10 @@ describe('class DYOToolsBunch', () => {
886
888
 
887
889
  test('string output standard with items and owner', () => {
888
890
  bunchTest.th_set_items(generateMockedElements(5));
889
- bunchTest.th_set_owner(new DTPlayerStub());
891
+ bunchTest.th_set_owner(OwnerTest);
890
892
 
891
893
  const toStringBunch = bunchTest.toString();
892
- expect(toStringBunch).toBe(`Component ${KeyTest} - Type: Bunch - Owner: ${KeyPlayerTest} - Items: 5`);
894
+ expect(toStringBunch).toBe(`Component ${KeyTest} - Type: Bunch - Owner: ${OwnerTest} - Items: 5`);
893
895
  });
894
896
  });
895
897
  });
@@ -1,6 +1,5 @@
1
1
  import {DTComponentPhysical} from "../../src";
2
2
  import {IMetaDataTest} from "./DTComponentWithMeta.double";
3
- import {DTPlayerStub} from "./DTPlayer.double";
4
3
 
5
4
  /******************** STUB PROPERTIES CONSTANTS
6
5
  * Fixed properties to use with double classes, avoid auto generated and easy checking on test
@@ -10,6 +9,7 @@ export const KeyTest = "DTComponentPhysical-key-1234567";
10
9
  export const ComponentTypeTest = "DTComponentPhysical-componentType-test";
11
10
  export const ToObjectTest = { type: "DTComponentPhysical-test-toObject" };
12
11
  export const ToStringTest = "DTComponentPhysical-test-toString";
12
+ export const OwnerTest = "owner-12345";
13
13
 
14
14
  /******************** STUB ABSTRACT IMPLEMENTATION
15
15
  * Implementation of abstract component class for tests
@@ -38,11 +38,11 @@ export class DTComponentPhysicalImpl extends DTComponentPhysical<IMetaDataTest>
38
38
  * Providing methods to property access and other facilities, in order to avoid using class methods
39
39
  * *****/
40
40
  export class DTComponentPhysicalTest extends DTComponentPhysicalImpl {
41
- th_get_owner(): DTPlayerStub {
41
+ th_get_owner(): string {
42
42
  return this._owner;
43
43
  }
44
44
 
45
- th_set_owner(owner: DTPlayerStub): void {
45
+ th_set_owner(owner: string): void {
46
46
  this._owner = owner;
47
47
  }
48
48
  }
@@ -1,7 +1,6 @@
1
- import {beforeEach, describe, jest, test} from '@jest/globals';
2
- import {DTPlayerStub, IDTest as IDPlayerTest,} from './DTPlayer.double';
1
+ import {beforeEach, describe, expect, jest, test} from '@jest/globals';
3
2
  import {mockOverriddenMethods} from "./DTComponentWithMeta.double";
4
- import {DTComponentPhysicalTest} from './DTComponentPhysical.double';
3
+ import {DTComponentPhysicalTest, OwnerTest} from './DTComponentPhysical.double';
5
4
  import {DTComponentPhysical, DTComponentWithMeta} from "../../src";
6
5
 
7
6
  /******************** MOCK DEPENDENCIES
@@ -30,32 +29,47 @@ describe('class DYOToolsComponentPhysical', () => {
30
29
  });
31
30
  });
32
31
 
32
+ describe('getManager()', () => {
33
+ test('call get context with manager accessor', () => {
34
+ componentPhysicalTest.getManager();
35
+
36
+ expect((componentPhysicalTest.getContext as any).mock.calls.length).toBe(1);
37
+ expect((componentPhysicalTest.getContext as any).mock.calls[0][0]).toBe('manager');
38
+ });
39
+ });
40
+
41
+ describe('getMaster()', () => {
42
+ test('call get context with master accessor', () => {
43
+ componentPhysicalTest.getMaster();
44
+
45
+ expect((componentPhysicalTest.getContext as any).mock.calls.length).toBe(1);
46
+ expect((componentPhysicalTest.getContext as any).mock.calls[0][0]).toBe('master');
47
+ });
48
+ });
49
+
33
50
  describe('getOwner()', () => {
34
51
  test('return empty owner by default', () => {
35
52
  expect(componentPhysicalTest.getOwner()).toBeUndefined();
36
53
  });
37
54
 
38
55
  test('return owner when set', () => {
39
- const owner = new DTPlayerStub();
40
- componentPhysicalTest.th_set_owner(owner);
56
+ componentPhysicalTest.th_set_owner(OwnerTest);
41
57
 
42
- expect(componentPhysicalTest.getOwner().getId()).toBe(IDPlayerTest);
58
+ expect(componentPhysicalTest.getOwner()).toBe(OwnerTest);
43
59
  });
44
60
  });
45
61
 
46
62
  describe('setOwner()', () => {
47
63
  test('add a new owner', () => {
48
- const owner = new DTPlayerStub();
49
- componentPhysicalTest.setOwner(owner);
64
+ componentPhysicalTest.setOwner(OwnerTest);
50
65
 
51
- expect(componentPhysicalTest.th_get_owner().getId()).toBe(IDPlayerTest);
66
+ expect(componentPhysicalTest.th_get_owner()).toBe(OwnerTest);
52
67
  });
53
68
  });
54
69
 
55
70
  describe('removeOwner()', () => {
56
71
  test('remove the current Owner', () => {
57
- const owner = new DTPlayerStub();
58
- componentPhysicalTest.th_set_owner(owner);
72
+ componentPhysicalTest.th_set_owner(OwnerTest);
59
73
 
60
74
  componentPhysicalTest.removeOwner();
61
75
  expect(componentPhysicalTest.th_get_owner()).toBeUndefined();
@@ -1,6 +1,5 @@
1
- import { DTElement } from '../../src';
2
- import { IMetaDataTest } from './DTComponentWithMeta.double';
3
- import { DTPlayerStub } from './DTPlayer.double';
1
+ import {DTBunch, DTElement} from '../../src';
2
+ import {IMetaDataTest} from './DTComponentWithMeta.double';
4
3
 
5
4
  /** ****************** STUB PROPERTIES CONSTANTS
6
5
  * Fixed properties to use with double classes, avoid auto generated and easy checking on test
@@ -8,6 +7,7 @@ import { DTPlayerStub } from './DTPlayer.double';
8
7
  // Global constants
9
8
  export const IDTest = 'DTElement-id-1234567';
10
9
  export const KeyTest = 'DTElement-key-1234567';
10
+ export const DomainTest = 'DTElement-domain-test';
11
11
 
12
12
  // Specific elements constants
13
13
  export const HaileiIdTest = 'DTElement-id-Hailei';
@@ -51,17 +51,33 @@ export class DTElementTest extends DTElement<IMetaDataTest> {
51
51
  return this._componentType;
52
52
  }
53
53
 
54
- th_get_owner(): DTPlayerStub {
54
+ th_get_domain(): string {
55
+ return this._domain;
56
+ }
57
+
58
+ th_set_domain(domain: string): void {
59
+ this._domain = domain;
60
+ }
61
+
62
+ th_get_owner(): string {
55
63
  return this._owner;
56
64
  }
57
65
 
58
- th_set_owner(owner: DTPlayerStub): void {
66
+ th_set_owner(owner: string): void {
59
67
  this._owner = owner;
60
68
  }
61
69
 
62
70
  th_set_meta(meta: IMetaDataTest): void {
63
71
  this._meta = meta;
64
72
  }
73
+
74
+ th_get_container(): DTBunch<any> | undefined {
75
+ return this._container;
76
+ }
77
+
78
+ th_set_container(container: DTBunch<any>): void {
79
+ this._container = container;
80
+ }
65
81
  }
66
82
  /** ****************** STUB CLASS
67
83
  * Stub class, for using in other component
@@ -1,9 +1,9 @@
1
1
  import {beforeEach, describe, expect, jest, test} from '@jest/globals';
2
- import {DTPlayerStub, KeyTest as KeyPlayerTest, toStringTest as toStringPlayerTest,} from './DTPlayer.double';
3
- import {DTElementTest, IDTest, KeyTest} from './DTElement.double';
2
+ import {DomainTest, DTElementTest, IDTest, KeyTest} from './DTElement.double';
4
3
  import {MeldrineMetaData} from './DTComponentWithMeta.double';
5
4
  import {DTComponentPhysical, DTElement} from "../../src";
6
- import {mockOverriddenMethods} from "./DTComponentPhysical.double";
5
+ import {mockOverriddenMethods, OwnerTest} from "./DTComponentPhysical.double";
6
+ import {DTBunchStub, IDTest as bunchIdTest} from "./DTBunch.double";
7
7
 
8
8
  /******************** MOCK DEPENDENCIES
9
9
  * All Dependencies used by the component are mocked with Jest
@@ -11,6 +11,7 @@ import {mockOverriddenMethods} from "./DTComponentPhysical.double";
11
11
  jest.mock('../../src/core/DTComponent');
12
12
  jest.mock('../../src/core/DTComponentWithMeta');
13
13
  jest.mock('../../src/core/DTComponentPhysical');
14
+ jest.mock('../../src/core/DTBunch');
14
15
  // Add specific mock for inherited methods to have a basic implementation
15
16
  mockOverriddenMethods(DTComponentPhysical);
16
17
 
@@ -38,6 +39,41 @@ describe('class DYOToolsElement', () => {
38
39
  });
39
40
  });
40
41
 
42
+ describe('getContainer()', () => {
43
+ test('return undefined if no container - default case', () => {
44
+ expect(elementTest.getContainer()).toBeUndefined();
45
+ });
46
+
47
+ test('return container', () => {
48
+ const container = new DTBunchStub();
49
+ elementTest.th_set_container(container);
50
+
51
+ expect(elementTest.getContainer()).toBeDefined();
52
+ expect(elementTest.getContainer().getId()).toStrictEqual(bunchIdTest);
53
+ });
54
+ });
55
+
56
+ describe('setContainer()', () => {
57
+ test('set a new container for element', () => {
58
+ const container = new DTBunchStub();
59
+
60
+ elementTest.setContainer(container);
61
+
62
+ expect(elementTest.th_get_container()).toBeDefined();
63
+ expect(elementTest.th_get_container().getId()).toStrictEqual(bunchIdTest);
64
+ });
65
+ });
66
+
67
+ describe('removeContainer()', () => {
68
+ test('remove the current container', () => {
69
+ const bunchContainer = new DTBunchStub();
70
+ elementTest.th_set_container(bunchContainer);
71
+
72
+ elementTest.removeContainer();
73
+ expect(elementTest.th_get_container()).toBeUndefined();
74
+ });
75
+ });
76
+
41
77
  describe('copy()', () => {
42
78
  // @see copy.spec.ts for unit tests about copy method
43
79
  })
@@ -58,19 +94,19 @@ describe('class DYOToolsElement', () => {
58
94
  });
59
95
 
60
96
  test('toObject output standard with owner', () => {
61
- elementTest.th_set_owner(new DTPlayerStub());
97
+ elementTest.th_set_owner(OwnerTest);
62
98
 
63
99
  const toObjectElement = elementTest.toObject();
64
100
 
65
101
  expect(Object.keys(toObjectElement)).toStrictEqual(['id', 'key', 'type', 'owner']);
66
- expect(toObjectElement.owner.toString()).toBe(toStringPlayerTest);
102
+ expect(toObjectElement.owner).toBe(OwnerTest);
67
103
  });
68
104
 
69
105
  test('toObject output standard with owner and meta', () => {
70
106
  jest.spyOn(elementTest, 'getManyMeta').mockImplementation(function () {
71
107
  return this._meta;
72
108
  });
73
- elementTest.th_set_owner(new DTPlayerStub());
109
+ elementTest.th_set_owner(OwnerTest);
74
110
  elementTest.th_set_meta(MeldrineMetaData);
75
111
 
76
112
  const toObjectElement = elementTest.toObject();
@@ -91,12 +127,20 @@ describe('class DYOToolsElement', () => {
91
127
  expect(toStringElement).toBe(`Component ${KeyTest} - Type: Element`);
92
128
  });
93
129
 
130
+ test('string output standard with domain', () => {
131
+ elementTest.th_set_domain(DomainTest);
132
+
133
+ const toStringElement = elementTest.toString();
134
+
135
+ expect(toStringElement).toBe(`Component ${DomainTest} ${KeyTest} - Type: Element`);
136
+ });
137
+
94
138
  test('string output standard with owner', () => {
95
- elementTest.th_set_owner(new DTPlayerStub());
139
+ elementTest.th_set_owner(OwnerTest);
96
140
 
97
141
  const toStringElement = elementTest.toString();
98
142
 
99
- expect(toStringElement).toBe(`Component ${KeyTest} - Type: Element - Owner: ${KeyPlayerTest}`);
143
+ expect(toStringElement).toBe(`Component ${KeyTest} - Type: Element - Owner: ${OwnerTest}`);
100
144
  });
101
145
  });
102
146
  });
@@ -1,7 +1,7 @@
1
1
  import {DTError} from '../../src';
2
2
  import {expect} from "@jest/globals";
3
- import {MockedFunction} from "ts-jest";
4
3
  import DYOToolsComponent from "../../src/core/DTComponent";
4
+ import MockedFunction = jest.MockedFunction;
5
5
 
6
6
  /******************** STUB PROPERTIES CONSTANTS
7
7
  * Fixed properties to use with double classes, avoid auto generated and easy checking on test
@@ -1,5 +1,5 @@
1
- import { expect } from '@jest/globals';
2
- import { DTManager, DTElement } from '../../src';
1
+ import {expect} from '@jest/globals';
2
+ import {DTElement, DTManager} from '../../src';
3
3
  import {
4
4
  bunch1IdTest,
5
5
  bunch1toObjectTest,
@@ -12,7 +12,7 @@ import {
12
12
  DTBunchTest,
13
13
  generateMockedElements,
14
14
  } from './DTBunch.double';
15
- import { DTAcceptedMetaData, DTManagerItemsType, DTManagerOptions } from '../../src/types';
15
+ import {DTAcceptedMetaData, DTManagerItemsType, DTManagerOptions, DTManagerToObject} from '../../src/types';
16
16
  import DYOFinder from '../../src/libs/DYOFinder';
17
17
 
18
18
  /** ****************** STUB PROPERTIES CONSTANTS
@@ -23,6 +23,22 @@ export const KeyTest = 'DTManager-key-1234567';
23
23
  export const DomainTest = 'DTManager-domain-test';
24
24
  export const ScopesTest = ['DTManager-scope-test1', 'DTManager-scope-test2'];
25
25
 
26
+ // Specific Manager constants
27
+ export const manager1IDTest = `${IDTest}_1`;
28
+ export const manager1KeyTest = `${KeyTest}_1`;
29
+
30
+ export const manager1ToObject: DTManagerToObject = {
31
+ id: manager1IDTest,
32
+ key: manager1KeyTest,
33
+ type: 'manager',
34
+ items: [
35
+ {
36
+ scope: 'default',
37
+ ...bunch1toObjectTest
38
+ }
39
+ ]
40
+ }
41
+
26
42
  /** ****************** HELPER TEST CLASS
27
43
  * Helper test class, inherits the main component
28
44
  * Providing methods to property access and other facilities, in order to avoid using class methods
@@ -48,6 +64,14 @@ export class DTManagerTest extends DTManager<DTElement<DTAcceptedMetaData>> {
48
64
  return this._componentType;
49
65
  }
50
66
 
67
+ th_get_domain(): string {
68
+ return this._domain;
69
+ }
70
+
71
+ th_set_domain(domain: string): void {
72
+ this._domain = domain;
73
+ }
74
+
51
75
  th_get_items(): any {
52
76
  return this._items;
53
77
  }
@@ -159,9 +183,9 @@ export function populateManager(manager: DTManagerTest): DTManagerTest {
159
183
  const bunch3 = new DTBunchTest();
160
184
  bunch3.th_set_items([]);
161
185
  bunch3.th_set_id(bunch3IdTest);
162
- bunch3.th_set_options({ virtualContext: true });
186
+ bunch3.th_set_options({ virtualContainer: true });
163
187
  jest.spyOn(bunch3, 'getId').mockImplementation(() => bunch3IdTest);
164
- jest.spyOn(bunch3, 'getOptions').mockImplementation(() => ({ ...defaultOptions, virtualContext: true }));
188
+ jest.spyOn(bunch3, 'getOptions').mockImplementation(() => ({ ...defaultOptions, virtualContainer: true }));
165
189
  jest.spyOn(bunch3, 'getAll').mockImplementation(function () { return this._items; });
166
190
  jest.spyOn(bunch3, 'toObject').mockImplementation(() => bunch3toObjectTest);
167
191