dyo-tools 0.3.2 → 0.4.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.
- package/.c8rc.json +4 -4
- package/.eslintignore +1 -1
- package/.eslintrc.json +47 -47
- package/Makefile +34 -34
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +24 -20
- package/dist/constants.js.map +1 -1
- package/dist/core/DTAction.d.ts +6 -4
- package/dist/core/DTAction.d.ts.map +1 -0
- package/dist/core/DTAction.js +3 -6
- package/dist/core/DTAction.js.map +1 -1
- package/dist/core/DTBunch.d.ts +8 -5
- package/dist/core/DTBunch.d.ts.map +1 -0
- package/dist/core/DTBunch.js +53 -19
- package/dist/core/DTBunch.js.map +1 -1
- package/dist/core/DTComponent.d.ts +13 -10
- package/dist/core/DTComponent.d.ts.map +1 -0
- package/dist/core/DTComponent.js +23 -10
- package/dist/core/DTComponent.js.map +1 -1
- package/dist/core/DTComponentPhysical.d.ts +11 -8
- package/dist/core/DTComponentPhysical.d.ts.map +1 -0
- package/dist/core/DTComponentPhysical.js +21 -6
- package/dist/core/DTComponentPhysical.js.map +1 -1
- package/dist/core/DTComponentWithMeta.d.ts +6 -3
- package/dist/core/DTComponentWithMeta.d.ts.map +1 -0
- package/dist/core/DTComponentWithMeta.js +21 -7
- package/dist/core/DTComponentWithMeta.js.map +1 -1
- package/dist/core/DTElement.d.ts +10 -8
- package/dist/core/DTElement.d.ts.map +1 -0
- package/dist/core/DTElement.js +8 -9
- package/dist/core/DTElement.js.map +1 -1
- package/dist/core/DTError.d.ts +8 -7
- package/dist/core/DTError.d.ts.map +1 -0
- package/dist/core/DTError.js +1 -5
- package/dist/core/DTError.js.map +1 -1
- package/dist/core/DTManager.d.ts +17 -14
- package/dist/core/DTManager.d.ts.map +1 -0
- package/dist/core/DTManager.js +84 -26
- package/dist/core/DTManager.js.map +1 -1
- package/dist/core/DTMaster.d.ts +19 -16
- package/dist/core/DTMaster.d.ts.map +1 -0
- package/dist/core/DTMaster.js +48 -31
- package/dist/core/DTMaster.js.map +1 -1
- package/dist/core/DTModule.d.ts +8 -5
- package/dist/core/DTModule.d.ts.map +1 -0
- package/dist/core/DTModule.js +6 -6
- package/dist/core/DTModule.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -28
- package/dist/index.js.map +1 -1
- package/dist/libs/DYOFinder.d.ts +1 -0
- package/dist/libs/DYOFinder.d.ts.map +1 -0
- package/dist/libs/DYOFinder.js +10 -14
- package/dist/libs/DYOFinder.js.map +1 -1
- package/dist/libs/dix/DIXModule.module.d.ts +8 -0
- package/dist/libs/dix/DIXModule.module.d.ts.map +1 -0
- package/dist/libs/dix/DIXModule.module.js +73 -0
- package/dist/libs/player/DTPlayer.element.d.ts +3 -2
- package/dist/libs/player/DTPlayer.element.d.ts.map +1 -0
- package/dist/libs/player/DTPlayer.element.js +2 -6
- package/dist/libs/player/DTPlayer.element.js.map +1 -1
- package/dist/libs/player/DTPlayer.manager.d.ts +8 -7
- package/dist/libs/player/DTPlayer.manager.d.ts.map +1 -0
- package/dist/libs/player/DTPlayer.manager.js +13 -20
- package/dist/libs/player/DTPlayer.manager.js.map +1 -1
- package/dist/tsconfig.dev.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/core.d.ts +40 -12
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/core.js +2 -6
- package/dist/types/core.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -19
- package/dist/types/index.js.map +1 -1
- package/dist/types/player.d.ts +1 -1
- package/dist/types/player.d.ts.map +1 -0
- package/dist/types/player.js +1 -3
- package/integration/data/components/DTHero.ts +42 -0
- package/integration/data/components/DTHeroManager.ts +11 -0
- package/integration/data/components/DTHeroPlayZone.ts +6 -0
- package/integration/data/components/DTHeroPlayerHand.ts +11 -0
- package/integration/data/components/index.ts +5 -0
- package/integration/data/in/heroIn.helper.ts +8 -0
- package/integration/data/in/playerIn.helper.ts +13 -0
- package/integration/data/out/heroOut.helper.ts +48 -0
- package/integration/endings/synchronisation.ending.ts +25 -0
- package/integration/scenes/drawCard.scene.ts +31 -0
- package/integration/scenes/empty.scene.ts +6 -0
- package/integration/scenes/playCard.scene.ts +23 -0
- package/integration/scenes/playerLeave.scene.ts +33 -0
- package/integration/stages/baseDix.stage.ts +137 -0
- package/integration/stages/syncDix.stage.ts +36 -0
- package/integration/tests/scenario1.spec.ts +55 -0
- package/integration/types/index.ts +24 -0
- package/jest-integration.config.ts +25 -0
- package/jest.config.ts +26 -0
- package/package.json +31 -19
- package/src/constants.ts +2 -0
- package/src/core/DTAction.ts +7 -5
- package/src/core/DTBunch.ts +78 -14
- package/src/core/DTComponent.ts +48 -15
- package/src/core/DTComponentPhysical.ts +45 -11
- package/src/core/DTComponentWithMeta.ts +37 -4
- package/src/core/DTElement.ts +19 -10
- package/src/core/DTError.ts +7 -7
- package/src/core/DTManager.ts +120 -30
- package/src/core/DTMaster.ts +76 -28
- package/src/core/DTModule.ts +12 -6
- package/src/index.ts +17 -17
- package/src/libs/DYOFinder.ts +175 -175
- package/src/libs/dix/DIXModule.module.ts +98 -0
- package/src/libs/player/DTPlayer.element.ts +2 -2
- package/src/libs/player/DTPlayer.manager.ts +20 -34
- package/src/types/core.ts +39 -4
- package/src/types/index.ts +2 -2
- package/src/types/player.ts +0 -1
- package/test/core/DTAction.double.ts +12 -28
- package/test/core/DTAction.spec.ts +8 -16
- package/test/core/DTBunch.double.ts +49 -135
- package/test/core/DTBunch.spec.ts +157 -245
- package/test/core/DTComponent.double.ts +17 -2
- package/test/core/DTComponent.spec.ts +6 -4
- package/test/core/DTComponentPhysical.double.ts +29 -43
- package/test/core/DTComponentPhysical.spec.ts +22 -19
- package/test/core/DTComponentWithMeta.double.ts +38 -31
- package/test/core/DTComponentWithMeta.spec.ts +23 -18
- package/test/core/DTElement.double.ts +32 -53
- package/test/core/DTElement.spec.ts +15 -38
- package/test/core/DTError.double.ts +18 -53
- package/test/core/DTError.spec.ts +21 -32
- package/test/core/DTManager.double.ts +74 -141
- package/test/core/DTManager.spec.ts +289 -380
- package/test/core/DTMaster.double.ts +56 -80
- package/test/core/DTMaster.spec.ts +185 -232
- package/test/core/DTModule.double.ts +12 -25
- package/test/core/DTModule.spec.ts +14 -28
- package/test/core/copy.spec.ts +9 -30
- package/tsconfig.dev.json +5 -8
- package/tsconfig.json +5 -8
- package/cucumber-report.html +0 -48
- package/docs/assets/navigation.js +0 -1
- package/docs/classes/core_DTAction.DYOToolsAction.html +0 -89
- package/docs/classes/core_DTBunch.DYOToolsBunch.html +0 -254
- package/docs/classes/core_DTComponent.DYOToolsComponent.html +0 -76
- package/docs/classes/core_DTComponentPhysical.DYOToolsComponentPhysical.html +0 -110
- package/docs/classes/core_DTComponentWithMeta.DYOToolsComponentWithMeta.html +0 -96
- package/docs/classes/core_DTElement.DYOToolsElement.html +0 -135
- package/docs/classes/core_DTError.DYOToolsError.html +0 -37
- package/docs/classes/core_DTManager.DYOToolsManager.html +0 -237
- package/docs/classes/core_DTMaster.DYOToolsMaster.html +0 -150
- package/docs/classes/core_DTModule.DYOToolsModule.html +0 -92
- package/docs/classes/libs_DYOFinder.DYOFinder.html +0 -34
- package/docs/classes/libs_player_DTPlayer_element.DYOToolsPlayer.html +0 -134
- package/docs/classes/libs_player_DTPlayer_manager.DYOToolsPlayerManager.html +0 -243
- package/docs/enums/types_core.FilterOperatorType.html +0 -10
- package/docs/hierarchy.html +0 -1
- package/docs/interfaces/types_core.DTBunchFilters.html +0 -6
- package/docs/interfaces/types_core.DTBunchOptions.html +0 -19
- package/docs/interfaces/types_core.DTBunchToObject.html +0 -7
- package/docs/interfaces/types_core.DTComponentOptions.html +0 -5
- package/docs/interfaces/types_core.DTComponentToObject.html +0 -4
- package/docs/interfaces/types_core.DTElementToObject.html +0 -7
- package/docs/interfaces/types_core.DTManagerFilters.html +0 -6
- package/docs/interfaces/types_core.DTManagerOptions.html +0 -8
- package/docs/interfaces/types_core.DTManagerToObject.html +0 -5
- package/docs/interfaces/types_core.DTMasterToObject.html +0 -8
- package/docs/interfaces/types_core.DTModuleToObject.html +0 -6
- package/docs/interfaces/types_core.DYOFinderConfigurationPropDefault.html +0 -4
- package/docs/interfaces/types_core.DYOFinderConfigurationPropObjectSearch.html +0 -4
- package/docs/interfaces/types_core.DYOFinderFilterOperatorAdvanced.html +0 -5
- package/docs/interfaces/types_core.DYOFinderFilterOperatorBase.html +0 -5
- package/docs/interfaces/types_player.DTPlayerManagerSimpleConfiguration.html +0 -3
- package/docs/modules/constants.html +0 -6
- package/docs/modules/core_DTAction.html +0 -2
- package/docs/modules/core_DTBunch.html +0 -2
- package/docs/modules/core_DTComponent.html +0 -2
- package/docs/modules/core_DTComponentPhysical.html +0 -2
- package/docs/modules/core_DTComponentWithMeta.html +0 -2
- package/docs/modules/core_DTElement.html +0 -2
- package/docs/modules/core_DTError.html +0 -2
- package/docs/modules/core_DTManager.html +0 -2
- package/docs/modules/core_DTMaster.html +0 -2
- package/docs/modules/core_DTModule.html +0 -2
- package/docs/modules/libs_DYOFinder.html +0 -2
- package/docs/modules/libs_player_DTPlayer_element.html +0 -2
- package/docs/modules/libs_player_DTPlayer_manager.html +0 -2
- package/docs/modules/types.html +0 -29
- package/docs/modules/types_core.html +0 -28
- package/docs/modules/types_player.html +0 -2
- package/docs/types/types_core.DTAcceptedMetaData.html +0 -2
- package/docs/types/types_core.DTManagerItemType.html +0 -1
- package/docs/types/types_core.DTManagerItemsType.html +0 -2
- package/docs/types/types_core.DYOFinderComponentType.html +0 -1
- package/docs/types/types_core.DYOFinderConfiguration.html +0 -2
- package/docs/types/types_core.DYOFinderConfigurationProp.html +0 -1
- package/docs/types/types_core.DYOFinderFilterOperator.html +0 -1
- package/docs/types/types_core.DYOFinderFilterOperatorArgument.html +0 -1
- package/docs/types/types_core.DYOFinderFilters.html +0 -1
- package/docs/types/types_core.StandardPrimitiveType.html +0 -2
- package/docs/types/types_core.StandardPrimitiveTypeWithArray.html +0 -1
- package/docs/variables/constants.bunchDefaultOptions.html +0 -2
- package/docs/variables/constants.componentBunchDefaultFinderConfiguration.html +0 -1
- package/docs/variables/constants.componentManagerDefaultFinderConfiguration.html +0 -1
- package/docs/variables/constants.componentPhysicalDefaultFinderConfiguration.html +0 -1
- package/docs/variables/constants.managerDefaultOptions.html +0 -2
- package/jest.config.js +0 -6
|
@@ -17,38 +17,22 @@ export const action1ToObject: DTComponentToObject = {
|
|
|
17
17
|
type: 'action'
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
/******************** STUB ABSTRACT IMPLEMENTATION
|
|
21
|
-
* Implementation of abstract component class for tests
|
|
22
|
-
* *****/
|
|
23
|
-
export class DTActionImpl extends DTAction<string> {
|
|
24
|
-
async execute(payload: string): Promise<void> {
|
|
25
|
-
throw `${this._key} : ${payload}`;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
20
|
/** ****************** HELPER TEST CLASS
|
|
30
21
|
* Helper test class, inherits the main component
|
|
31
22
|
* Providing methods to property access and other facilities, in order to avoid using class methods
|
|
32
23
|
* **** */
|
|
33
|
-
export class DTActionTest extends
|
|
34
|
-
th_get_id(): string {
|
|
35
|
-
return this._id;
|
|
36
|
-
}
|
|
24
|
+
export class DTActionTest extends DTAction<string> {
|
|
37
25
|
|
|
38
|
-
|
|
26
|
+
constructor(
|
|
27
|
+
id: string = IDTest,
|
|
28
|
+
key: string = KeyTest,
|
|
29
|
+
) {
|
|
30
|
+
super(key);
|
|
39
31
|
this._id = id;
|
|
40
32
|
}
|
|
41
33
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
th_set_key(key: string): void {
|
|
47
|
-
this._key = key;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
th_get_componentType(): string {
|
|
51
|
-
return this._componentType;
|
|
34
|
+
async execute(payload: string): Promise<void> {
|
|
35
|
+
throw `${this._key} : ${payload}`;
|
|
52
36
|
}
|
|
53
37
|
}
|
|
54
38
|
|
|
@@ -64,12 +48,12 @@ export class DTActionStub extends DTActionTest {
|
|
|
64
48
|
this._errors = [];
|
|
65
49
|
}
|
|
66
50
|
|
|
67
|
-
|
|
68
|
-
|
|
51
|
+
_setId(id: string) {
|
|
52
|
+
this._id = id;
|
|
69
53
|
}
|
|
70
54
|
|
|
71
|
-
|
|
72
|
-
|
|
55
|
+
_setKey(key: string) {
|
|
56
|
+
this._key = key;
|
|
73
57
|
}
|
|
74
58
|
}
|
|
75
59
|
|
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {mockOverriddenMethods} from "./DTComponent.double";
|
|
1
|
+
import {DTAction, DTComponent} from "../../src";
|
|
3
2
|
import {afterEach, beforeEach, describe, expect, jest, test} from "@jest/globals";
|
|
4
3
|
import {DTActionTest, IDTest, KeyTest} from "./DTAction.double";
|
|
5
4
|
|
|
6
|
-
/** ****************** MOCK DEPENDENCIES
|
|
7
|
-
* Dependencies used by the component are mocked with Jest
|
|
8
|
-
* **** */
|
|
9
|
-
jest.mock('../../src/core/DTComponent');
|
|
10
|
-
jest.mock('../../src/core/DTError');
|
|
11
|
-
// Add specific mock for inherited methods to have a basic implementation
|
|
12
|
-
mockOverriddenMethods(DTComponent);
|
|
13
|
-
|
|
14
5
|
/** *********************** TESTS SUITES ****************************** */
|
|
15
|
-
describe('class
|
|
6
|
+
describe('class DTAction' +
|
|
7
|
+
'', () => {
|
|
16
8
|
let actionTest: DTActionTest;
|
|
17
9
|
|
|
18
10
|
beforeEach(() => {
|
|
19
11
|
actionTest = new DTActionTest();
|
|
20
|
-
actionTest.th_set_id(IDTest);
|
|
21
|
-
actionTest.th_set_key(KeyTest);
|
|
22
12
|
});
|
|
23
13
|
|
|
24
14
|
afterEach(() => {
|
|
@@ -33,16 +23,18 @@ describe('class DYOToolsAction', () => {
|
|
|
33
23
|
|
|
34
24
|
describe('_componentType', () => {
|
|
35
25
|
test('componentType must be "action"', () => {
|
|
36
|
-
expect(actionTest.
|
|
26
|
+
expect(actionTest.getComponentType()).toBe('action');
|
|
37
27
|
});
|
|
38
28
|
});
|
|
39
29
|
|
|
40
30
|
describe('getMaster', () => {
|
|
41
31
|
test('call get context with master accessor', () => {
|
|
32
|
+
const getContextSpy = jest.spyOn(actionTest, 'getContext');
|
|
33
|
+
|
|
42
34
|
actionTest.getMaster();
|
|
43
35
|
|
|
44
|
-
expect(
|
|
45
|
-
expect(
|
|
36
|
+
expect(getContextSpy.mock.calls.length).toBe(1);
|
|
37
|
+
expect(getContextSpy.mock.calls[0][0]).toBe('master');
|
|
46
38
|
});
|
|
47
39
|
});
|
|
48
40
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {DTBunch
|
|
2
|
-
import {bunchDefaultOptions as DTBunchDefaultOptions} from '../../src/constants';
|
|
1
|
+
import {DTBunch} from '../../src';
|
|
2
|
+
import {bunchDefaultOptions, bunchDefaultOptions as DTBunchDefaultOptions} from '../../src/constants';
|
|
3
3
|
import {
|
|
4
4
|
HaileiMetaData,
|
|
5
5
|
IldressMetaData,
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
MeldrineMetaData,
|
|
9
9
|
YssaliaMetaData,
|
|
10
10
|
} from './DTComponentWithMeta.double';
|
|
11
|
-
import
|
|
12
|
-
import {DTBunchOptions, DTElementToObject} from '../../src/types';
|
|
11
|
+
import {DIXObject, DTBunchOptions, DTElementToObject} from '../../src/types';
|
|
13
12
|
import {
|
|
13
|
+
DTElementStub,
|
|
14
14
|
HaileiIdTest,
|
|
15
15
|
HaileiKeyTest,
|
|
16
16
|
HaileiToObjectTest,
|
|
@@ -27,9 +27,6 @@ import {
|
|
|
27
27
|
YssaliaKeyTest,
|
|
28
28
|
YssaliaToObjectTest,
|
|
29
29
|
} from './DTElement.double';
|
|
30
|
-
import {DTErrorStub} from './DTError.double';
|
|
31
|
-
import DYOFinder from '../../src/libs/DYOFinder';
|
|
32
|
-
import Mocked = jest.Mocked;
|
|
33
30
|
|
|
34
31
|
/** ****************** STUB PROPERTIES CONSTANTS
|
|
35
32
|
* Fixed properties to use with double classes, avoid auto generated and easy checking on test
|
|
@@ -38,91 +35,47 @@ import Mocked = jest.Mocked;
|
|
|
38
35
|
export const IDTest = 'DTBunch-id-1234567';
|
|
39
36
|
export const IDTestLibrary = 'DTBunch-id-library-1234567';
|
|
40
37
|
export const KeyTest = 'DTBunch-key-1234567';
|
|
41
|
-
export const defaultOptions: DTBunchOptions = DTBunchDefaultOptions;
|
|
42
38
|
|
|
43
39
|
// Specific Bunch constants
|
|
44
40
|
export const bunch1IdTest = `${IDTest}_1`;
|
|
45
41
|
export const bunch1toObjectTest = {
|
|
46
|
-
id: bunch1IdTest, key:
|
|
42
|
+
id: bunch1IdTest, key: KeyTest, type: 'bunch', items: [
|
|
43
|
+
HaileiToObjectTest,
|
|
44
|
+
MeldrineToObjectTest,
|
|
45
|
+
MaydenaToObjectTest,
|
|
46
|
+
IldressToObjectTest,
|
|
47
|
+
YssaliaToObjectTest
|
|
48
|
+
],
|
|
47
49
|
};
|
|
48
50
|
export const bunch2IdTest = `${IDTest}_2`;
|
|
49
51
|
export const bunch2toObjectTest = {
|
|
50
|
-
id: bunch2IdTest, key:
|
|
52
|
+
id: bunch2IdTest, key: KeyTest, type: 'bunch', items: [],
|
|
51
53
|
};
|
|
52
54
|
export const bunch3IdTest = `${IDTest}_3`;
|
|
53
55
|
export const bunch3toObjectTest = {
|
|
54
|
-
id: bunch3IdTest, key:
|
|
56
|
+
id: bunch3IdTest, key: KeyTest, type: 'bunch', items: [],
|
|
55
57
|
};
|
|
56
58
|
|
|
59
|
+
|
|
57
60
|
/** ****************** HELPER TEST CLASS
|
|
58
61
|
* Helper test class, inherits the main component
|
|
59
62
|
* Providing methods to property access and other facilities, in order to avoid using class methods
|
|
60
63
|
* **** */
|
|
61
|
-
export class DTBunchTest extends DTBunch<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
export class DTBunchTest extends DTBunch<DTElementStub, IMetaDataTest> {
|
|
65
|
+
|
|
66
|
+
constructor(
|
|
67
|
+
id: string = IDTest,
|
|
68
|
+
key: string = KeyTest,
|
|
69
|
+
items: DTElementStub[] = [],
|
|
70
|
+
options: Partial<DTBunchOptions> = bunchDefaultOptions,
|
|
71
|
+
owner: string | undefined = undefined,
|
|
72
|
+
) {
|
|
73
|
+
super(key, items, options);
|
|
67
74
|
this._id = id;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
th_get_key(): string {
|
|
71
|
-
return this._key;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
th_set_key(key: string): void {
|
|
75
|
-
this._key = key;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
th_get_componentType(): string {
|
|
79
|
-
return this._componentType;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
th_get_context(): DTComponent | undefined {
|
|
83
|
-
return this._context;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
th_set_context(context: DTComponent): void {
|
|
87
|
-
this._context = context;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
th_get_items(): Mocked<DYOToolsElement<IMetaDataTest>>[] {
|
|
91
|
-
return this._items;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
th_set_items(items: Mocked<DYOToolsElement<IMetaDataTest>>[]): void {
|
|
95
|
-
this._items = items;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
th_set_errors(errors: Array<DTErrorStub>): void {
|
|
99
|
-
this._errors = errors;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
th_get_options(): any {
|
|
103
|
-
return this._options;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
th_set_options(options: any): void {
|
|
107
|
-
this._options = {
|
|
108
|
-
...this._options,
|
|
109
|
-
...options,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
th_get_owner(): string {
|
|
114
|
-
return this._owner;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
th_set_owner(owner: string): void {
|
|
118
75
|
this._owner = owner;
|
|
119
76
|
}
|
|
120
77
|
|
|
121
|
-
|
|
122
|
-
this._meta = meta;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
th_get_finder(): DYOFinder {
|
|
78
|
+
_getFinder() {
|
|
126
79
|
return this._finder;
|
|
127
80
|
}
|
|
128
81
|
}
|
|
@@ -130,37 +83,28 @@ export class DTBunchTest extends DTBunch<Mocked<DYOToolsElement<IMetaDataTest>>,
|
|
|
130
83
|
/** ****************** STUB CLASS
|
|
131
84
|
* Stub class, for using in other component
|
|
132
85
|
* **** */
|
|
133
|
-
export class DTBunchStub extends
|
|
134
|
-
constructor(items: Array<
|
|
86
|
+
export class DTBunchStub extends DTBunch<DTElementStub> {
|
|
87
|
+
constructor(items: Array<DTElementStub> = [], options: Partial<DTBunchOptions> = {}) {
|
|
135
88
|
super();
|
|
136
89
|
this._id = IDTest;
|
|
137
90
|
this._key = KeyTest;
|
|
138
91
|
this._errors = [];
|
|
139
92
|
this._items = items;
|
|
140
|
-
this._options =
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return IDTest;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
getKey(): string {
|
|
148
|
-
return KeyTest;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
getAll(): Array<Mocked<DYOToolsElement<IMetaDataTest>>> {
|
|
152
|
-
return this._items;
|
|
93
|
+
this._options = {
|
|
94
|
+
...DTBunchDefaultOptions,
|
|
95
|
+
...options,
|
|
96
|
+
};
|
|
153
97
|
}
|
|
154
98
|
|
|
155
|
-
|
|
156
|
-
|
|
99
|
+
_setId(id: string) {
|
|
100
|
+
this._id = id;
|
|
157
101
|
}
|
|
158
102
|
}
|
|
159
103
|
|
|
160
104
|
// Specific Stub Library for Manager
|
|
161
|
-
export class DTBunchStubLibrary extends
|
|
162
|
-
constructor(items: Array<
|
|
163
|
-
super(
|
|
105
|
+
export class DTBunchStubLibrary extends DTBunch<DTElementStub> {
|
|
106
|
+
constructor(items: Array<DTElementStub> = []) {
|
|
107
|
+
super();
|
|
164
108
|
this._id = IDTestLibrary;
|
|
165
109
|
this._key = 'library';
|
|
166
110
|
this._errors = [];
|
|
@@ -170,29 +114,15 @@ export class DTBunchStubLibrary extends DTBunchStub {
|
|
|
170
114
|
virtualContainer: true,
|
|
171
115
|
};
|
|
172
116
|
}
|
|
173
|
-
|
|
174
|
-
getId(): string {
|
|
175
|
-
return IDTestLibrary;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
getKey(): string {
|
|
179
|
-
return 'library';
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
get(id: string): Mocked<DYOToolsElement<IMetaDataTest>> | undefined {
|
|
183
|
-
const itemFiltered = this._items.filter((item: Mocked<DYOToolsElement<IMetaDataTest>>) => item.getId() === id);
|
|
184
|
-
return itemFiltered.length > 0 ? itemFiltered[0] : undefined;
|
|
185
|
-
}
|
|
186
117
|
}
|
|
187
118
|
|
|
188
119
|
/** ****************** HELPER METHODS
|
|
189
120
|
* Additional helper methods to use with testing
|
|
190
121
|
* **** */
|
|
191
122
|
|
|
192
|
-
// Function to generate
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const mockedElements = [];
|
|
123
|
+
// Function to generate Stub DTElement collection
|
|
124
|
+
export const generateStubElements = (numberElements: number, owner?: string): DTElementStub[] => {
|
|
125
|
+
const mockedElements: DTElementStub[] = [];
|
|
196
126
|
const mockedData: Array<{ id: string, key: string, meta: IMetaDataTest, toObject: DTElementToObject<IMetaDataTest> }> = [
|
|
197
127
|
{
|
|
198
128
|
id: HaileiIdTest,
|
|
@@ -227,35 +157,19 @@ export const generateMockedElements = (numberElements: number): Array<Mocked<DYO
|
|
|
227
157
|
];
|
|
228
158
|
|
|
229
159
|
for (let i = 0; i < numberElements; i++) {
|
|
230
|
-
const
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
mockedElement.getContext.mockImplementation(function () {
|
|
240
|
-
return this._context;
|
|
241
|
-
});
|
|
242
|
-
mockedElement.setOwner.mockImplementation(function (owner) {
|
|
243
|
-
this._owner = owner;
|
|
244
|
-
});
|
|
245
|
-
mockedElement.getOwner.mockImplementation(function () {
|
|
246
|
-
return this._owner;
|
|
247
|
-
});
|
|
248
|
-
mockedElement.setContainer.mockImplementation(function (container) {
|
|
249
|
-
this._container = container;
|
|
250
|
-
});
|
|
251
|
-
mockedElement.getContainer.mockImplementation(function () {
|
|
252
|
-
return this._container;
|
|
253
|
-
});
|
|
254
|
-
mockedElement.copy.mockReturnValue(mockedElement);
|
|
255
|
-
mockedElement.toObject.mockReturnValue(mockedData[selectedMock].toObject);
|
|
160
|
+
const selectedData = i % 5;
|
|
161
|
+
const mockedElement = new DTElementStub(
|
|
162
|
+
0,
|
|
163
|
+
(mockedData[selectedData].id + "-" + i),
|
|
164
|
+
mockedData[selectedData].key,
|
|
165
|
+
mockedData[selectedData].meta,
|
|
166
|
+
owner,
|
|
167
|
+
mockedData[selectedData].toObject,
|
|
168
|
+
);
|
|
256
169
|
|
|
257
170
|
mockedElements.push(mockedElement);
|
|
258
171
|
}
|
|
259
172
|
|
|
260
173
|
return mockedElements;
|
|
261
174
|
};
|
|
175
|
+
|