dyo-tools 0.2.0 → 0.3.2

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 (164) 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 +17 -14
  8. package/dist/core/DTBunch.js.map +1 -1
  9. package/dist/core/DTComponentPhysical.d.ts +7 -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 +4 -3
  45. package/docs/assets/navigation.js +1 -0
  46. package/docs/assets/search.js +1 -1
  47. package/docs/assets/style.css +72 -25
  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 +4 -4
  115. package/src/core/DTAction.ts +52 -0
  116. package/src/core/DTBunch.ts +36 -30
  117. package/src/core/DTComponent.ts +1 -1
  118. package/src/core/DTComponentPhysical.ts +20 -5
  119. package/src/core/DTElement.ts +35 -2
  120. package/src/core/DTManager.ts +37 -18
  121. package/src/core/DTMaster.ts +318 -0
  122. package/src/core/DTModule.ts +90 -0
  123. package/src/index.ts +9 -1
  124. package/src/libs/player/DTPlayer.element.ts +9 -0
  125. package/src/libs/player/DTPlayer.manager.ts +84 -0
  126. package/src/types/core.ts +169 -0
  127. package/src/types/index.ts +2 -162
  128. package/src/types/player.ts +6 -0
  129. package/test/core/DTAction.double.ts +78 -0
  130. package/test/core/DTAction.spec.ts +76 -0
  131. package/test/core/DTBunch.double.ts +18 -10
  132. package/test/core/DTBunch.spec.ts +83 -68
  133. package/test/core/DTComponentPhysical.double.ts +3 -3
  134. package/test/core/DTComponentPhysical.spec.ts +25 -11
  135. package/test/core/DTElement.double.ts +21 -5
  136. package/test/core/DTElement.spec.ts +52 -8
  137. package/test/core/DTError.double.ts +1 -1
  138. package/test/core/DTManager.double.ts +29 -5
  139. package/test/core/DTManager.spec.ts +80 -17
  140. package/test/core/DTMaster.double.ts +141 -0
  141. package/test/core/DTMaster.spec.ts +584 -0
  142. package/test/core/DTModule.double.ts +80 -0
  143. package/test/core/DTModule.spec.ts +138 -0
  144. package/test/core/copy.spec.ts +20 -4
  145. package/test/{core/DTPlayer.double.ts → libs/player/DTPlayer.element.double.ts} +15 -24
  146. package/test/libs/player/DTPlayer.element.spec.ts +28 -0
  147. package/test/libs/player/DTPlayer.manager.double.ts +92 -0
  148. package/test/libs/player/DTPlayer.manager.spec.ts +178 -0
  149. package/LICENSE +0 -21
  150. package/cucumber.js +0 -9
  151. package/dist/core/DTPlayer.d.ts +0 -8
  152. package/dist/core/DTPlayer.js +0 -30
  153. package/dist/core/DTPlayer.js.map +0 -1
  154. package/e2e/0.2.0/epic1.feature +0 -29
  155. package/e2e/0.2.0/epic2.feature +0 -22
  156. package/e2e/0.2.0/epic3.feature +0 -25
  157. package/e2e/0.2.0/resources/dominion.js +0 -195
  158. package/e2e/0.2.0/resources/utils.js +0 -27
  159. package/e2e/0.2.0/support/steps.js +0 -108
  160. package/e2e/future/epic4.feature +0 -39
  161. package/e2e/future/resources/dominion.js +0 -238
  162. package/e2e/future/resources/utils.js +0 -27
  163. package/src/core/DTPlayer.ts +0 -57
  164. package/test/core/DTPlayer.spec.ts +0 -80
@@ -1,4 +1,4 @@
1
- import { afterEach, beforeEach, describe, expect, jest, test, } from '@jest/globals';
1
+ import {afterEach, beforeEach, describe, expect, jest, test,} from '@jest/globals';
2
2
  import {
3
3
  checkManagerItem,
4
4
  DomainTest,
@@ -17,20 +17,21 @@ import {
17
17
  bunch2toObjectTest,
18
18
  bunch3toObjectTest,
19
19
  DTBunchStub,
20
- DTBunchStubLibrary, DTBunchTest,
20
+ DTBunchStubLibrary,
21
+ DTBunchTest,
21
22
  generateMockedElements,
22
23
  IDTest as IDTestBunch,
23
24
  IDTestLibrary,
24
25
  KeyTest as KeyTestBunch,
25
26
  } from './DTBunch.double';
26
- import { mockOverriddenMethods } from './DTComponent.double';
27
- import { DTComponent, DTComponentPhysical, DTElement } from '../../src';
27
+ import {mockOverriddenMethods} from './DTComponent.double';
28
+ import {DTComponent, DTComponentPhysical, DTElement} from '../../src';
28
29
  import DYOToolsError from '../../src/core/DTError';
29
- import { checkCallForMockedDTError, DTErrorStub } from './DTError.double';
30
- import { BunchMetaData, IMetaDataTest } from './DTComponentWithMeta.double';
31
- import { componentManagerDefaultFinderConfiguration, managerDefaultOptions } from '../../src/constants';
32
- import { FilterOperatorType } from '../../src/types';
33
- import { DTPlayerStub, IDTest as IDTestPlayer } from './DTPlayer.double';
30
+ import {checkCallForMockedDTError, DTErrorStub} from './DTError.double';
31
+ import {BunchMetaData, IMetaDataTest} from './DTComponentWithMeta.double';
32
+ import {componentManagerDefaultFinderConfiguration, managerDefaultOptions} from '../../src/constants';
33
+ import {FilterOperatorType} from '../../src/types';
34
+ import {OwnerTest} from './DTComponentPhysical.double';
34
35
  import MockedFunction = jest.MockedFunction;
35
36
 
36
37
  /** ****************** MOCK DEPENDENCIES
@@ -63,7 +64,7 @@ describe('class DYOToolsManager', () => {
63
64
  });
64
65
 
65
66
  describe('_componentType', () => {
66
- test('componentType must be "bunch"', () => {
67
+ test('componentType must be "manager"', () => {
67
68
  expect(managerTest.th_get_componentType()).toBe('manager');
68
69
  });
69
70
  });
@@ -88,7 +89,9 @@ describe('class DYOToolsManager', () => {
88
89
  expect(newManager.th_get_library().constructor.mock.calls.length).toBe(1);
89
90
  expect(newManager.th_get_library().constructor.mock.calls[0][0]).toBe('library');
90
91
  expect(newManager.th_get_library().constructor.mock.calls[0][1]).toStrictEqual([]);
91
- expect(newManager.th_get_library().constructor.mock.calls[0][2].virtualContext).toBe(true);
92
+ expect(newManager.th_get_library().constructor.mock.calls[0][2].virtualContainer).toBe(true);
93
+ expect(newManager.th_get_library().setContext.mock.calls.length).toBe(1);
94
+ expect(newManager.th_get_library().setContext.mock.calls[0][0]).toStrictEqual(newManager);
92
95
 
93
96
  // Finder initialization
94
97
  expect((newManager.th_get_finder() as any).constructor.mock.calls.length).toBe(1);
@@ -97,6 +100,9 @@ describe('class DYOToolsManager', () => {
97
100
  });
98
101
 
99
102
  test('creation simple without key - use domain if defined', () => {
103
+ // Warning : this method doesn't really work because of Javascript
104
+ // The property _domain set is only available after constructing (not during)
105
+
100
106
  const newManager = new DTManager();
101
107
  const newManagerWithDomain = new DTManagerStubDomain();
102
108
  const newManagerWithDomain2 = new DTManagerStubDomain(null);
@@ -129,7 +135,9 @@ describe('class DYOToolsManager', () => {
129
135
  expect(newManager.th_get_library().constructor.mock.calls[0][1].length).toStrictEqual(5);
130
136
  expect(newManager.th_get_library().constructor.mock.calls[0][1].map((item) => item.getId()))
131
137
  .toStrictEqual(mockedElements.map((item) => item.getId()));
132
- expect(newManager.th_get_library().constructor.mock.calls[0][2].virtualContext).toBe(true);
138
+ expect(newManager.th_get_library().constructor.mock.calls[0][2].virtualContainer).toBe(true);
139
+ expect(newManager.th_get_library().setContext.mock.calls.length).toBe(1);
140
+ expect(newManager.th_get_library().setContext.mock.calls[0][0]).toStrictEqual(newManager);
133
141
  });
134
142
 
135
143
  test('creation with extended scopes', () => {
@@ -195,18 +203,18 @@ describe('class DYOToolsManager', () => {
195
203
  const finderConfigurationToCheck = managerTest.getFinderConfiguration().owner;
196
204
 
197
205
  expect(finderConfigurationToCheck.operators).toStrictEqual(baseOperators);
198
- expect(finderConfigurationToCheck.getValue(bunch)).toBeNull();
206
+ expect(finderConfigurationToCheck.getValue(bunch)).toBeUndefined();
199
207
  expect(finderConfigurationToCheck.objectSearch).toBe(false);
200
208
  });
201
209
 
202
210
  test('check finder configuration for owner attribute - with owner', () => {
203
211
  const bunch = new DTBunchStub();
204
- jest.spyOn(bunch, 'getOwner').mockImplementation(() => new DTPlayerStub());
212
+ jest.spyOn(bunch, 'getOwner').mockReturnValue(OwnerTest);
205
213
 
206
214
  const finderConfigurationToCheck = managerTest.getFinderConfiguration().owner;
207
215
 
208
216
  expect(finderConfigurationToCheck.operators).toStrictEqual(baseOperators);
209
- expect(finderConfigurationToCheck.getValue(bunch)).toBe(IDTestPlayer);
217
+ expect(finderConfigurationToCheck.getValue(bunch)).toBe(OwnerTest);
210
218
  expect(finderConfigurationToCheck.objectSearch).toBe(false);
211
219
  });
212
220
 
@@ -251,6 +259,15 @@ describe('class DYOToolsManager', () => {
251
259
  });
252
260
  });
253
261
 
262
+ describe('getMaster()', () => {
263
+ test('call get context with master accessor', () => {
264
+ managerTest.getMaster();
265
+
266
+ expect((managerTest.getContext as any).mock.calls.length).toBe(1);
267
+ expect((managerTest.getContext as any).mock.calls[0][0]).toBe('master');
268
+ });
269
+ });
270
+
254
271
  describe('isValidScope()', () => {
255
272
  beforeEach(() => {
256
273
  managerTest.th_set_scopes(ScopesTest);
@@ -303,7 +320,7 @@ describe('class DYOToolsManager', () => {
303
320
  });
304
321
 
305
322
  test('add a new item - virtual bunch in virtual scope', () => {
306
- bunchToAdd.th_set_options({ virtualContext: true });
323
+ bunchToAdd.th_set_options({ virtualContainer: true });
307
324
 
308
325
  managerTest.add(bunchToAdd);
309
326
 
@@ -331,7 +348,7 @@ describe('class DYOToolsManager', () => {
331
348
  });
332
349
 
333
350
  test('trigger error if invalid scope for virtual bunch', () => {
334
- bunchToAdd.th_set_options({ virtualContext: true });
351
+ bunchToAdd.th_set_options({ virtualContainer: true });
335
352
  const mockedTriggerError = DTManager.prototype.triggerError as MockedFunction<(error: DYOToolsError) => void>;
336
353
 
337
354
  managerTest.add(bunchToAdd, ScopesTest[0]);
@@ -438,6 +455,20 @@ describe('class DYOToolsManager', () => {
438
455
  expect(Object.keys(managerTest.th_get_items()).length).toBe(1);
439
456
  checkManagerItem(managerTest, IDTestBunch, 'default');
440
457
  });
458
+
459
+ test('set context when adding an item - update context with manager for all library elements', () => {
460
+ const oldManagerTest = new DTManagerTest();
461
+ const bunchElements = generateMockedElements(5);
462
+ bunchToAdd.th_set_items(bunchElements);
463
+ bunchToAdd.th_set_context(oldManagerTest);
464
+
465
+ managerTest.add(bunchToAdd);
466
+
467
+ for (const element of bunchElements) {
468
+ expect((element.setContext as any).mock.calls.length).toBe(1);
469
+ expect((element.setContext as any).mock.calls[0][0]).toStrictEqual(managerTest);
470
+ }
471
+ });
441
472
  });
442
473
 
443
474
  describe('addMany()', () => {
@@ -759,6 +790,29 @@ describe('class DYOToolsManager', () => {
759
790
  expect(managerTest.th_get_library().remove.mock.calls.length).toBe(5);
760
791
  expect(managerTest.th_get_library().remove.mock.calls.map((call: any) => call[0])).toEqual(libraryElementsIdToRemove);
761
792
  });
793
+
794
+ test('remove context when removing a bunch - standard case', () => {
795
+ const bunch1 = managerTest.th_get_single_item(`${IDTestBunch}_1`).item;
796
+ const bunch2 = managerTest.th_get_single_item(`${IDTestBunch}_2`).item;
797
+
798
+ managerTest.removeMany([`${IDTestBunch}_1`, `${IDTestBunch}_2`]);
799
+
800
+ expect((bunch1.removeContext as any).mock.calls.length).toBe(1);
801
+ expect((bunch2.removeContext as any).mock.calls.length).toBe(1);
802
+ });
803
+
804
+ test('remove context when removing a bunch - remove context for all library elements', () => {
805
+ const bunch1 = managerTest.th_get_single_item(`${IDTestBunch}_1`).item;
806
+ const bunchElements = generateMockedElements(5);
807
+ bunch1.th_set_items(bunchElements);
808
+ bunch1.th_set_context(managerTest);
809
+
810
+ managerTest.removeMany([`${IDTestBunch}_1`]);
811
+
812
+ for (let element of bunchElements) {
813
+ expect((element.removeContext as any).mock.calls.length).toBe(1);
814
+ }
815
+ });
762
816
  });
763
817
 
764
818
  describe('removeAll()', () => {
@@ -882,6 +936,15 @@ describe('class DYOToolsManager', () => {
882
936
  expect(toStringManager).toBe(`Component ${KeyTest} - Type: Manager - Library: 0 - Items: 0`);
883
937
  });
884
938
 
939
+ test('string output with domain', () => {
940
+ managerTest.th_set_library(new DTBunchStubLibrary());
941
+ managerTest.th_set_domain(DomainTest);
942
+
943
+ const toStringManager = managerTest.toString();
944
+
945
+ expect(toStringManager).toBe(`Component ${DomainTest} ${KeyTest} - Type: Manager - Library: 0 - Items: 0`);
946
+ });
947
+
885
948
  test('string output with library', () => {
886
949
  populateManager(managerTest);
887
950
  managerTest.th_set_items({});
@@ -0,0 +1,141 @@
1
+ import {expect, jest} from "@jest/globals";
2
+ import {DTAction, DTManager, DTMaster, DTModule} from "../../src";
3
+ import {DTManagerStub, IDTest as IDManagerTest, manager1IDTest, manager1KeyTest} from "./DTManager.double";
4
+ import {DTActionStub, IDTest as IDActionTest, action1IDTest, action1KeyTest} from "./DTAction.double";
5
+ import {DTModuleStub, IDTest as IDModuleTest, module1IDTest, module1KeyTest} from "./DTModule.double";
6
+
7
+ /** ****************** STUB PROPERTIES CONSTANTS
8
+ * Fixed properties to use with double classes, avoid auto generated and easy checking on test
9
+ * **** */
10
+ export const IDTest = 'DTMaster-id-1234567';
11
+ export const KeyTest = 'DTMaster-key-1234567';
12
+
13
+ /** ****************** HELPER TEST CLASS
14
+ * Helper test class, inherits the main component
15
+ * Providing methods to property access and other facilities, in order to avoid using class methods
16
+ * **** */
17
+ export class DTMasterTest extends DTMaster {
18
+ th_get_id(): string {
19
+ return this._id;
20
+ }
21
+
22
+ th_set_id(id: string): void {
23
+ this._id = id;
24
+ }
25
+
26
+ th_get_key(): string {
27
+ return this._key;
28
+ }
29
+
30
+ th_set_key(key: string): void {
31
+ this._key = key;
32
+ }
33
+
34
+ th_get_componentType(): string {
35
+ return this._componentType;
36
+ }
37
+
38
+ th_get_managers(): Record<string, DTManager<any>> {
39
+ return this._managers;
40
+ }
41
+
42
+ th_set_managers(managers: Record<string, DTManager<any>>): void {
43
+ this._managers = managers;
44
+ }
45
+
46
+ th_get_actions(): Record<string, DTAction> {
47
+ return this._actions;
48
+ }
49
+
50
+ th_set_actions(actions: Record<string, DTAction>): void {
51
+ this._actions = actions;
52
+ }
53
+
54
+ th_get_modules(): Record<string, DTModule> {
55
+ return this._modules;
56
+ }
57
+
58
+ th_set_modules(modules: Record<string, DTModule>): void {
59
+ this._modules = modules;
60
+ }
61
+ }
62
+
63
+
64
+ /** ****************** STUB CLASS
65
+ * Stub class, for using in other component
66
+ * **** */
67
+
68
+ /** ****************** HELPER METHODS
69
+ * Additional helper methods to use with testing
70
+ * **** */
71
+ export const checkMasterManagers = (master: DTMasterTest, ids: string[]) => {
72
+ let i = 0;
73
+ expect(Object.keys(master.th_get_managers()).length).toBe(ids.length);
74
+ for (let [id, manager] of Object.entries(master.th_get_managers())) {
75
+ expect(id).toBe(ids[i]);
76
+ expect(manager.getId()).toBe(ids[i]);
77
+ i++;
78
+ }
79
+ }
80
+
81
+ export const checkMasterActions = (master: DTMasterTest, ids: string[]) => {
82
+ let i = 0;
83
+ expect(Object.keys(master.th_get_actions()).length).toBe(ids.length);
84
+ for (let [id, action] of Object.entries(master.th_get_actions())) {
85
+ expect(id).toBe(ids[i]);
86
+ expect(action.getId()).toBe(ids[i]);
87
+ i++;
88
+ }
89
+ }
90
+
91
+ export const checkMasterModules = (master: DTMasterTest, ids: string[]) => {
92
+ let i = 0;
93
+ expect(Object.keys(master.th_get_modules()).length).toBe(ids.length);
94
+ for (let [id, module] of Object.entries(master.th_get_modules())) {
95
+ expect(id).toBe(ids[i]);
96
+ expect(module.getId()).toBe(ids[i]);
97
+ i++;
98
+ }
99
+ }
100
+
101
+ export const populateMaster = (master: DTMasterTest) => {
102
+ // Managers
103
+ const manager1 = new DTManagerStub();
104
+ const manager2 = new DTManagerStub();
105
+ manager2.th_set_id(manager1IDTest);
106
+ manager2.th_set_key(manager1KeyTest);
107
+ jest.spyOn(manager2, 'getId').mockReturnValue(manager1IDTest);
108
+ jest.spyOn(manager2, 'getKey').mockReturnValue(manager1KeyTest);
109
+
110
+ master.th_set_managers({
111
+ [IDManagerTest]: manager1,
112
+ [manager1IDTest]: manager2
113
+ });
114
+
115
+ // Actions
116
+ const action1 = new DTActionStub();
117
+ const action2 = new DTActionStub();
118
+ action2.th_set_id(action1IDTest);
119
+ action2.th_set_key(action1KeyTest);
120
+ jest.spyOn(action2, 'getId').mockReturnValue(action1IDTest);
121
+ jest.spyOn(action2, 'getKey').mockReturnValue(action1KeyTest);
122
+
123
+ master.th_set_actions({
124
+ [IDActionTest]: action1,
125
+ [action1IDTest]: action2
126
+ });
127
+
128
+ // Modules
129
+ const module1 = new DTModuleStub();
130
+ const module2 = new DTModuleStub();
131
+ module2.th_set_id(module1IDTest);
132
+ module2.th_set_key(module1KeyTest);
133
+ module2.th_set_enabled(false);
134
+ jest.spyOn(module2, 'getId').mockReturnValue(module1IDTest);
135
+ jest.spyOn(module2, 'getKey').mockReturnValue(module1KeyTest);
136
+
137
+ master.th_set_modules({
138
+ [IDModuleTest]: module1,
139
+ [module1IDTest]: module2
140
+ });
141
+ }