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.
- package/dist/constants.js +4 -4
- package/dist/constants.js.map +1 -1
- package/dist/core/DTAction.d.ts +10 -0
- package/dist/core/DTAction.js +24 -0
- package/dist/core/DTAction.js.map +1 -0
- package/dist/core/DTBunch.d.ts +6 -7
- package/dist/core/DTBunch.js +17 -14
- package/dist/core/DTBunch.js.map +1 -1
- package/dist/core/DTComponentPhysical.d.ts +7 -4
- package/dist/core/DTComponentPhysical.js +6 -0
- package/dist/core/DTComponentPhysical.js.map +1 -1
- package/dist/core/DTElement.d.ts +5 -0
- package/dist/core/DTElement.js +12 -2
- package/dist/core/DTElement.js.map +1 -1
- package/dist/core/DTManager.d.ts +3 -1
- package/dist/core/DTManager.js +24 -14
- package/dist/core/DTManager.js.map +1 -1
- package/dist/core/DTMaster.d.ts +24 -0
- package/dist/core/DTMaster.js +133 -0
- package/dist/core/DTMaster.js.map +1 -0
- package/dist/core/DTModule.d.ts +14 -0
- package/dist/core/DTModule.js +39 -0
- package/dist/core/DTModule.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/libs/player/DTPlayer.element.d.ts +5 -0
- package/dist/libs/player/DTPlayer.element.js +11 -0
- package/dist/libs/player/DTPlayer.element.js.map +1 -0
- package/dist/libs/player/DTPlayer.manager.d.ts +11 -0
- package/dist/libs/player/DTPlayer.manager.js +42 -0
- package/dist/libs/player/DTPlayer.manager.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/core.d.ts +103 -0
- package/dist/types/core.js +15 -0
- package/dist/types/core.js.map +1 -0
- package/dist/types/index.d.ts +2 -98
- package/dist/types/index.js +16 -12
- package/dist/types/index.js.map +1 -1
- package/dist/types/player.d.ts +5 -0
- package/dist/types/player.js +3 -0
- package/dist/types/player.js.map +1 -0
- package/docs/assets/highlight.css +29 -29
- package/docs/assets/main.js +4 -3
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +72 -25
- package/docs/classes/core_DTAction.DYOToolsAction.html +89 -0
- package/docs/classes/core_DTBunch.DYOToolsBunch.html +254 -0
- package/docs/classes/core_DTComponent.DYOToolsComponent.html +76 -0
- package/docs/classes/core_DTComponentPhysical.DYOToolsComponentPhysical.html +110 -0
- package/docs/classes/core_DTComponentWithMeta.DYOToolsComponentWithMeta.html +96 -0
- package/docs/classes/core_DTElement.DYOToolsElement.html +135 -0
- package/docs/classes/core_DTError.DYOToolsError.html +37 -0
- package/docs/classes/core_DTManager.DYOToolsManager.html +237 -0
- package/docs/classes/core_DTMaster.DYOToolsMaster.html +150 -0
- package/docs/classes/core_DTModule.DYOToolsModule.html +92 -0
- package/docs/classes/libs_DYOFinder.DYOFinder.html +34 -0
- package/docs/classes/libs_player_DTPlayer_element.DYOToolsPlayer.html +134 -0
- package/docs/classes/libs_player_DTPlayer_manager.DYOToolsPlayerManager.html +243 -0
- package/docs/enums/types_core.FilterOperatorType.html +10 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +1 -46
- package/docs/interfaces/types_core.DTBunchFilters.html +6 -0
- package/docs/interfaces/types_core.DTBunchOptions.html +19 -0
- package/docs/interfaces/types_core.DTBunchToObject.html +7 -0
- package/docs/interfaces/types_core.DTComponentOptions.html +5 -0
- package/docs/interfaces/types_core.DTComponentToObject.html +4 -0
- package/docs/interfaces/types_core.DTElementToObject.html +7 -0
- package/docs/interfaces/types_core.DTManagerFilters.html +6 -0
- package/docs/interfaces/types_core.DTManagerOptions.html +8 -0
- package/docs/interfaces/types_core.DTManagerToObject.html +5 -0
- package/docs/interfaces/types_core.DTMasterToObject.html +8 -0
- package/docs/interfaces/types_core.DTModuleToObject.html +6 -0
- package/docs/interfaces/types_core.DYOFinderConfigurationPropDefault.html +4 -0
- package/docs/interfaces/types_core.DYOFinderConfigurationPropObjectSearch.html +4 -0
- package/docs/interfaces/types_core.DYOFinderFilterOperatorAdvanced.html +5 -0
- package/docs/interfaces/types_core.DYOFinderFilterOperatorBase.html +5 -0
- package/docs/interfaces/types_player.DTPlayerManagerSimpleConfiguration.html +3 -0
- package/docs/modules/constants.html +6 -0
- package/docs/modules/core_DTAction.html +2 -0
- package/docs/modules/core_DTBunch.html +2 -0
- package/docs/modules/core_DTComponent.html +2 -0
- package/docs/modules/core_DTComponentPhysical.html +2 -0
- package/docs/modules/core_DTComponentWithMeta.html +2 -0
- package/docs/modules/core_DTElement.html +2 -0
- package/docs/modules/core_DTError.html +2 -0
- package/docs/modules/core_DTManager.html +2 -0
- package/docs/modules/core_DTMaster.html +2 -0
- package/docs/modules/core_DTModule.html +2 -0
- package/docs/modules/libs_DYOFinder.html +2 -0
- package/docs/modules/libs_player_DTPlayer_element.html +2 -0
- package/docs/modules/libs_player_DTPlayer_manager.html +2 -0
- package/docs/modules/types.html +29 -0
- package/docs/modules/types_core.html +28 -0
- package/docs/modules/types_player.html +2 -0
- package/docs/types/types_core.DTAcceptedMetaData.html +2 -0
- package/docs/types/types_core.DTManagerItemType.html +1 -0
- package/docs/types/types_core.DTManagerItemsType.html +2 -0
- package/docs/types/types_core.DYOFinderComponentType.html +1 -0
- package/docs/types/types_core.DYOFinderConfiguration.html +2 -0
- package/docs/types/types_core.DYOFinderConfigurationProp.html +1 -0
- package/docs/types/types_core.DYOFinderFilterOperator.html +1 -0
- package/docs/types/types_core.DYOFinderFilterOperatorArgument.html +1 -0
- package/docs/types/types_core.DYOFinderFilters.html +1 -0
- package/docs/types/types_core.StandardPrimitiveType.html +2 -0
- package/docs/types/types_core.StandardPrimitiveTypeWithArray.html +1 -0
- package/docs/variables/constants.bunchDefaultOptions.html +2 -0
- package/docs/variables/constants.componentBunchDefaultFinderConfiguration.html +1 -0
- package/docs/variables/constants.componentManagerDefaultFinderConfiguration.html +1 -0
- package/docs/variables/constants.componentPhysicalDefaultFinderConfiguration.html +1 -0
- package/docs/variables/constants.managerDefaultOptions.html +2 -0
- package/package.json +16 -17
- package/src/constants.ts +4 -4
- package/src/core/DTAction.ts +52 -0
- package/src/core/DTBunch.ts +36 -30
- package/src/core/DTComponent.ts +1 -1
- package/src/core/DTComponentPhysical.ts +20 -5
- package/src/core/DTElement.ts +35 -2
- package/src/core/DTManager.ts +37 -18
- package/src/core/DTMaster.ts +318 -0
- package/src/core/DTModule.ts +90 -0
- package/src/index.ts +9 -1
- package/src/libs/player/DTPlayer.element.ts +9 -0
- package/src/libs/player/DTPlayer.manager.ts +84 -0
- package/src/types/core.ts +169 -0
- package/src/types/index.ts +2 -162
- package/src/types/player.ts +6 -0
- package/test/core/DTAction.double.ts +78 -0
- package/test/core/DTAction.spec.ts +76 -0
- package/test/core/DTBunch.double.ts +18 -10
- package/test/core/DTBunch.spec.ts +83 -68
- package/test/core/DTComponentPhysical.double.ts +3 -3
- package/test/core/DTComponentPhysical.spec.ts +25 -11
- package/test/core/DTElement.double.ts +21 -5
- package/test/core/DTElement.spec.ts +52 -8
- package/test/core/DTError.double.ts +1 -1
- package/test/core/DTManager.double.ts +29 -5
- package/test/core/DTManager.spec.ts +80 -17
- package/test/core/DTMaster.double.ts +141 -0
- package/test/core/DTMaster.spec.ts +584 -0
- package/test/core/DTModule.double.ts +80 -0
- package/test/core/DTModule.spec.ts +138 -0
- package/test/core/copy.spec.ts +20 -4
- package/test/{core/DTPlayer.double.ts → libs/player/DTPlayer.element.double.ts} +15 -24
- package/test/libs/player/DTPlayer.element.spec.ts +28 -0
- package/test/libs/player/DTPlayer.manager.double.ts +92 -0
- package/test/libs/player/DTPlayer.manager.spec.ts +178 -0
- package/LICENSE +0 -21
- package/cucumber.js +0 -9
- package/dist/core/DTPlayer.d.ts +0 -8
- package/dist/core/DTPlayer.js +0 -30
- package/dist/core/DTPlayer.js.map +0 -1
- package/e2e/0.2.0/epic1.feature +0 -29
- package/e2e/0.2.0/epic2.feature +0 -22
- package/e2e/0.2.0/epic3.feature +0 -25
- package/e2e/0.2.0/resources/dominion.js +0 -195
- package/e2e/0.2.0/resources/utils.js +0 -27
- package/e2e/0.2.0/support/steps.js +0 -108
- package/e2e/future/epic4.feature +0 -39
- package/e2e/future/resources/dominion.js +0 -238
- package/e2e/future/resources/utils.js +0 -27
- package/src/core/DTPlayer.ts +0 -57
- package/test/core/DTPlayer.spec.ts +0 -80
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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,
|
|
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 {
|
|
27
|
-
import {
|
|
27
|
+
import {mockOverriddenMethods} from './DTComponent.double';
|
|
28
|
+
import {DTComponent, DTComponentPhysical, DTElement} from '../../src';
|
|
28
29
|
import DYOToolsError from '../../src/core/DTError';
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
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 "
|
|
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].
|
|
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].
|
|
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)).
|
|
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').
|
|
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(
|
|
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({
|
|
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({
|
|
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
|
+
}
|