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
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {DTComponent} from "../../src";
|
|
2
2
|
import {DTErrorStub} from "./DTError.double";
|
|
3
3
|
import {jest} from "@jest/globals";
|
|
4
|
-
import {DTComponentOptions} from "../../src/types";
|
|
4
|
+
import {DIXObject, DTComponentOptions, DTComponentToDIXObject} from "../../src/types";
|
|
5
|
+
import * as domain from "domain";
|
|
5
6
|
|
|
6
7
|
interface IOptionsTest extends DTComponentOptions {
|
|
7
8
|
option1: boolean
|
|
@@ -18,6 +19,14 @@ export const ToObjectTest = { type: "DTComponent-test-toObject" };
|
|
|
18
19
|
export const ToStringTest = "DTComponent-test-toString";
|
|
19
20
|
export const DomainTest = "DTComponent-domain-test";
|
|
20
21
|
export const SubKindTest = "DTComponent-subkind-test";
|
|
22
|
+
export const ToDIXObjectTest = {
|
|
23
|
+
[IDTest]: {
|
|
24
|
+
key: KeyTest,
|
|
25
|
+
componentType: ComponentTypeTest,
|
|
26
|
+
domain: DomainTest,
|
|
27
|
+
subKind: SubKindTest,
|
|
28
|
+
}
|
|
29
|
+
}
|
|
21
30
|
|
|
22
31
|
/******************** STUB ABSTRACT IMPLEMENTATION
|
|
23
32
|
* Implementation of abstract component class for tests
|
|
@@ -36,6 +45,9 @@ export class DTComponentImpl extends DTComponent<IOptionsTest> {
|
|
|
36
45
|
toString(): string {
|
|
37
46
|
return ToStringTest;
|
|
38
47
|
}
|
|
48
|
+
|
|
49
|
+
updateFromDix(dix: Record<string, DIXObject>): void {
|
|
50
|
+
}
|
|
39
51
|
}
|
|
40
52
|
|
|
41
53
|
/******************** HELPER TEST CLASS
|
|
@@ -94,6 +106,9 @@ export class DTComponentTest extends DTComponentImpl {
|
|
|
94
106
|
th_set_options(options: any): void {
|
|
95
107
|
this._options = options;
|
|
96
108
|
}
|
|
109
|
+
|
|
110
|
+
updateFromDix(dix: Record<string, DIXObject>): void {
|
|
111
|
+
}
|
|
97
112
|
}
|
|
98
113
|
|
|
99
114
|
/******************** STUB CLASS
|
|
@@ -107,7 +122,7 @@ export class DTComponentStub extends DTComponentTest {
|
|
|
107
122
|
this.stubId = IDTest + (idSuffix && `-${idSuffix}`);
|
|
108
123
|
}
|
|
109
124
|
|
|
110
|
-
|
|
125
|
+
_getStubId(): string {
|
|
111
126
|
return this.stubId;
|
|
112
127
|
}
|
|
113
128
|
}
|
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
ComponentTypeTest,
|
|
4
4
|
DomainTest,
|
|
5
5
|
DTComponentTest,
|
|
6
|
-
DTComponentImpl,
|
|
7
6
|
IDTest,
|
|
8
7
|
KeyTest,
|
|
9
8
|
simulateHierarchy,
|
|
10
9
|
SubKindTest,
|
|
10
|
+
ToDIXObjectTest,
|
|
11
11
|
} from './DTComponent.double';
|
|
12
12
|
import {DTErrorStub} from "./DTError.double";
|
|
13
13
|
|
|
14
|
-
describe('class
|
|
14
|
+
describe('class DTComponent', () => {
|
|
15
15
|
let componentTest: DTComponentTest;
|
|
16
16
|
|
|
17
17
|
beforeEach(() => {
|
|
@@ -49,15 +49,17 @@ describe('class DYOToolsComponent', () => {
|
|
|
49
49
|
const component = new DTComponentTest();
|
|
50
50
|
|
|
51
51
|
expect(component.th_get_options()).toStrictEqual({
|
|
52
|
-
errors: false
|
|
52
|
+
errors: false,
|
|
53
|
+
syncId: undefined,
|
|
53
54
|
});
|
|
54
55
|
});
|
|
55
56
|
|
|
56
57
|
test('creations with options', () => {
|
|
57
|
-
const component = new DTComponentTest(KeyTest, { errors: true, option1: false, option2: true });
|
|
58
|
+
const component = new DTComponentTest(KeyTest, { errors: true, option1: false, option2: true, syncId: "123" });
|
|
58
59
|
|
|
59
60
|
expect(component.th_get_options()).toStrictEqual({
|
|
60
61
|
errors: true,
|
|
62
|
+
syncId: "123",
|
|
61
63
|
option1: false,
|
|
62
64
|
option2: true
|
|
63
65
|
});
|
|
@@ -10,26 +10,19 @@ export const ComponentTypeTest = "DTComponentPhysical-componentType-test";
|
|
|
10
10
|
export const ToObjectTest = { type: "DTComponentPhysical-test-toObject" };
|
|
11
11
|
export const ToStringTest = "DTComponentPhysical-test-toString";
|
|
12
12
|
export const OwnerTest = "owner-12345";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
protected _componentType: string = ComponentTypeTest;
|
|
19
|
-
|
|
20
|
-
copy(): DTComponentPhysical<IMetaDataTest> {
|
|
21
|
-
return this;
|
|
13
|
+
export const ParentToDIXObjectTest = {
|
|
14
|
+
[IDTest]: {
|
|
15
|
+
key: KeyTest,
|
|
16
|
+
componentType: ComponentTypeTest,
|
|
17
|
+
meta: {}
|
|
22
18
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
do(): void {
|
|
19
|
+
}
|
|
20
|
+
export const ToDIXObjectTest = {
|
|
21
|
+
[IDTest]: {
|
|
22
|
+
key: KeyTest,
|
|
23
|
+
componentType: ComponentTypeTest,
|
|
24
|
+
meta: {},
|
|
25
|
+
owner: OwnerTest,
|
|
33
26
|
}
|
|
34
27
|
}
|
|
35
28
|
|
|
@@ -37,40 +30,33 @@ export class DTComponentPhysicalImpl extends DTComponentPhysical<IMetaDataTest>
|
|
|
37
30
|
* Helper test class, inherits the main component
|
|
38
31
|
* Providing methods to property access and other facilities, in order to avoid using class methods
|
|
39
32
|
* *****/
|
|
40
|
-
export class DTComponentPhysicalTest extends
|
|
41
|
-
|
|
42
|
-
return this._owner;
|
|
43
|
-
}
|
|
33
|
+
export class DTComponentPhysicalTest extends DTComponentPhysical<IMetaDataTest> {
|
|
34
|
+
protected _componentType: string = ComponentTypeTest;
|
|
44
35
|
|
|
45
|
-
|
|
36
|
+
constructor(
|
|
37
|
+
id: string = IDTest,
|
|
38
|
+
key: string = KeyTest,
|
|
39
|
+
owner?: string,
|
|
40
|
+
) {
|
|
41
|
+
super(key);
|
|
42
|
+
this._id = id;
|
|
46
43
|
this._owner = owner;
|
|
47
44
|
}
|
|
48
|
-
}
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export class DTComponentPhysicalStub extends DTComponentPhysicalTest {
|
|
54
|
-
private readonly stubId: string;
|
|
46
|
+
copy(): DTComponentPhysical<IMetaDataTest> {
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
55
49
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.stubId = IDTest + (idSuffix && `-${idSuffix}`);
|
|
50
|
+
toObject(): any {
|
|
51
|
+
return ToObjectTest;
|
|
59
52
|
}
|
|
60
53
|
|
|
61
|
-
|
|
62
|
-
return
|
|
54
|
+
toString(): string {
|
|
55
|
+
return ToStringTest;
|
|
63
56
|
}
|
|
64
57
|
}
|
|
65
58
|
|
|
66
59
|
/******************** HELPER METHODS
|
|
67
60
|
* Additional helper methods to use with testing
|
|
68
61
|
* *****/
|
|
69
|
-
|
|
70
|
-
export function mockOverriddenMethods(mock: any) {
|
|
71
|
-
// Constructor
|
|
72
|
-
mock.prototype.constructor.mockImplementation(function (key?: string) {
|
|
73
|
-
this._id = IDTest;
|
|
74
|
-
this._key = key || this._id;
|
|
75
|
-
})
|
|
76
|
-
}
|
|
62
|
+
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
|
2
|
-
import {
|
|
3
|
-
import {DTComponentPhysicalTest, OwnerTest} from './DTComponentPhysical.double';
|
|
2
|
+
import {DTComponentPhysicalTest, IDTest, KeyTest, OwnerTest} from './DTComponentPhysical.double';
|
|
4
3
|
import {DTComponentPhysical, DTComponentWithMeta} from "../../src";
|
|
5
4
|
|
|
6
|
-
/******************** MOCK DEPENDENCIES
|
|
7
|
-
* All Dependencies used by the component are mocked with Jest
|
|
8
|
-
* *****/
|
|
9
|
-
jest.mock('../../src/core/DTComponent');
|
|
10
|
-
jest.mock('../../src/core/DTComponentWithMeta');
|
|
11
|
-
// Add specific mock for inherited methods to have a basic implementation
|
|
12
|
-
mockOverriddenMethods(DTComponentWithMeta);
|
|
13
|
-
|
|
14
5
|
/************************* TESTS SUITES *******************************/
|
|
15
|
-
describe('class
|
|
6
|
+
describe('class DTComponentPhysical', () => {
|
|
16
7
|
let componentPhysicalTest: DTComponentPhysicalTest;
|
|
17
8
|
|
|
18
9
|
beforeEach(() => {
|
|
@@ -31,19 +22,23 @@ describe('class DYOToolsComponentPhysical', () => {
|
|
|
31
22
|
|
|
32
23
|
describe('getManager()', () => {
|
|
33
24
|
test('call get context with manager accessor', () => {
|
|
25
|
+
const getContextSpy = jest.spyOn(componentPhysicalTest, 'getContext');
|
|
26
|
+
|
|
34
27
|
componentPhysicalTest.getManager();
|
|
35
28
|
|
|
36
|
-
expect(
|
|
37
|
-
expect(
|
|
29
|
+
expect(getContextSpy.mock.calls.length).toBe(1);
|
|
30
|
+
expect(getContextSpy.mock.calls[0][0]).toBe('manager');
|
|
38
31
|
});
|
|
39
32
|
});
|
|
40
33
|
|
|
41
34
|
describe('getMaster()', () => {
|
|
42
35
|
test('call get context with master accessor', () => {
|
|
36
|
+
const getContextSpy = jest.spyOn(componentPhysicalTest, 'getContext');
|
|
37
|
+
|
|
43
38
|
componentPhysicalTest.getMaster();
|
|
44
39
|
|
|
45
|
-
expect(
|
|
46
|
-
expect(
|
|
40
|
+
expect(getContextSpy.mock.calls.length).toBe(1);
|
|
41
|
+
expect(getContextSpy.mock.calls[0][0]).toBe('master');
|
|
47
42
|
});
|
|
48
43
|
});
|
|
49
44
|
|
|
@@ -53,7 +48,7 @@ describe('class DYOToolsComponentPhysical', () => {
|
|
|
53
48
|
});
|
|
54
49
|
|
|
55
50
|
test('return owner when set', () => {
|
|
56
|
-
componentPhysicalTest
|
|
51
|
+
componentPhysicalTest = new DTComponentPhysicalTest(IDTest, KeyTest, OwnerTest);
|
|
57
52
|
|
|
58
53
|
expect(componentPhysicalTest.getOwner()).toBe(OwnerTest);
|
|
59
54
|
});
|
|
@@ -63,16 +58,24 @@ describe('class DYOToolsComponentPhysical', () => {
|
|
|
63
58
|
test('add a new owner', () => {
|
|
64
59
|
componentPhysicalTest.setOwner(OwnerTest);
|
|
65
60
|
|
|
66
|
-
expect(componentPhysicalTest.
|
|
61
|
+
expect(componentPhysicalTest.getOwner()).toBe(OwnerTest);
|
|
67
62
|
});
|
|
68
63
|
});
|
|
69
64
|
|
|
70
65
|
describe('removeOwner()', () => {
|
|
71
66
|
test('remove the current Owner', () => {
|
|
72
|
-
componentPhysicalTest
|
|
67
|
+
componentPhysicalTest = new DTComponentPhysicalTest(IDTest, KeyTest, OwnerTest);
|
|
73
68
|
|
|
74
69
|
componentPhysicalTest.removeOwner();
|
|
75
|
-
expect(componentPhysicalTest.
|
|
70
|
+
expect(componentPhysicalTest.getOwner()).toBeUndefined();
|
|
76
71
|
});
|
|
77
72
|
});
|
|
73
|
+
|
|
74
|
+
// describe('toDIXObject()', () => {
|
|
75
|
+
// test('return parent and owner', () => {
|
|
76
|
+
// const dixObject = componentPhysicalTest.toDIXObject();
|
|
77
|
+
//
|
|
78
|
+
// expect(dixObject).toStrictEqual(ToDIXObjectTest);
|
|
79
|
+
// });
|
|
80
|
+
// });
|
|
78
81
|
});
|
|
@@ -67,49 +67,56 @@ export const BunchMetaData: IMetaDataTest = {
|
|
|
67
67
|
kd: [117, 3],
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
toString(): string {
|
|
85
|
-
return ToStringTest;
|
|
86
|
-
}
|
|
70
|
+
// DIX
|
|
71
|
+
export const ParentToDIXObjectTest = {
|
|
72
|
+
[IDTest]: {
|
|
73
|
+
key: KeyTest,
|
|
74
|
+
componentType: ComponentTypeTest
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export const ToDIXObjectTest = {
|
|
78
|
+
[IDTest]: {
|
|
79
|
+
key: KeyTest,
|
|
80
|
+
componentType: ComponentTypeTest,
|
|
81
|
+
meta: JSON.stringify(HaileiMetaData),
|
|
82
|
+
}
|
|
87
83
|
}
|
|
88
84
|
|
|
89
85
|
/******************** HELPER TEST CLASS
|
|
90
86
|
* Helper test class, inherits the main component
|
|
91
87
|
* Providing methods to property access and other facilities, in order to avoid using class methods
|
|
92
88
|
* *****/
|
|
93
|
-
export class DTComponentWithMetaTest extends
|
|
94
|
-
|
|
89
|
+
export class DTComponentWithMetaTest extends DTComponentWithMeta<IMetaDataTest> {
|
|
90
|
+
protected _componentType: string = ComponentTypeTest;
|
|
91
|
+
|
|
92
|
+
constructor(
|
|
93
|
+
id: string = IDTest,
|
|
94
|
+
key: string = KeyTest,
|
|
95
|
+
meta: Partial<IMetaDataTest> = {},
|
|
96
|
+
) {
|
|
97
|
+
super(IDTest);
|
|
98
|
+
this._id = id;
|
|
99
|
+
this._meta = meta;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
_getMeta(): Partial<IMetaDataTest> {
|
|
95
103
|
return this._meta;
|
|
96
104
|
}
|
|
97
105
|
|
|
98
|
-
|
|
99
|
-
this
|
|
106
|
+
copy(): DTComponentWithMeta<IMetaDataTest> {
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
toObject(): any {
|
|
111
|
+
return ToObjectTest;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
toString(): string {
|
|
115
|
+
return ToStringTest;
|
|
100
116
|
}
|
|
101
117
|
}
|
|
102
118
|
|
|
103
119
|
/******************** HELPER METHODS
|
|
104
120
|
* Additional helper methods to use with testing
|
|
105
121
|
* *****/
|
|
106
|
-
|
|
107
|
-
export function mockOverriddenMethods(mock: any) {
|
|
108
|
-
// Constructor
|
|
109
|
-
mock.prototype.constructor.mockImplementation(function (key?: string) {
|
|
110
|
-
this._id = IDTest;
|
|
111
|
-
this._key = key || this._id;
|
|
112
|
-
this._errors = [];
|
|
113
|
-
return this;
|
|
114
|
-
})
|
|
115
|
-
}
|
|
122
|
+
|
|
@@ -2,21 +2,16 @@ import {afterEach, beforeEach, describe, expect, jest, test,} from '@jest/global
|
|
|
2
2
|
import {
|
|
3
3
|
DTComponentWithMetaTest,
|
|
4
4
|
HaileiMetaData,
|
|
5
|
+
IDTest,
|
|
5
6
|
IMetaDataTest,
|
|
7
|
+
KeyTest,
|
|
6
8
|
MeldrineMetaData,
|
|
7
9
|
YssaliaMetaData
|
|
8
10
|
} from './DTComponentWithMeta.double';
|
|
9
|
-
import {mockOverriddenMethods} from "./DTComponent.double";
|
|
10
11
|
import {DTComponent, DTComponentWithMeta} from "../../src";
|
|
11
12
|
|
|
12
|
-
/******************** MOCK DEPENDENCIES
|
|
13
|
-
* All Dependencies used by the component are mocked with Jest
|
|
14
|
-
* *****/
|
|
15
|
-
jest.mock('../../src/core/DTComponent');
|
|
16
|
-
mockOverriddenMethods(DTComponent);
|
|
17
|
-
|
|
18
13
|
/************************* TESTS SUITES *******************************/
|
|
19
|
-
describe('class
|
|
14
|
+
describe('class DTComponentWithMeta', () => {
|
|
20
15
|
let componentWithMetaTest: DTComponentWithMetaTest;
|
|
21
16
|
|
|
22
17
|
beforeEach(() => {
|
|
@@ -39,7 +34,7 @@ describe('class DYOToolsComponentWithMeta', () => {
|
|
|
39
34
|
});
|
|
40
35
|
|
|
41
36
|
test('return one meta by key', () => {
|
|
42
|
-
componentWithMetaTest
|
|
37
|
+
componentWithMetaTest = new DTComponentWithMetaTest(IDTest, KeyTest, { ...HaileiMetaData });
|
|
43
38
|
|
|
44
39
|
expect(componentWithMetaTest.getMeta('name')).toBe(HaileiMetaData.name);
|
|
45
40
|
});
|
|
@@ -47,10 +42,10 @@ describe('class DYOToolsComponentWithMeta', () => {
|
|
|
47
42
|
|
|
48
43
|
describe('setMeta()', () => {
|
|
49
44
|
test('set a new value for a meta', () => {
|
|
50
|
-
componentWithMetaTest
|
|
45
|
+
componentWithMetaTest = new DTComponentWithMetaTest(IDTest, KeyTest, { ...HaileiMetaData });
|
|
51
46
|
componentWithMetaTest.setMeta('name', MeldrineMetaData.name);
|
|
52
47
|
|
|
53
|
-
const newMeta = componentWithMetaTest.
|
|
48
|
+
const newMeta = componentWithMetaTest._getMeta();
|
|
54
49
|
expect(newMeta.name === MeldrineMetaData.name).toBeTruthy();
|
|
55
50
|
expect(newMeta.rank === HaileiMetaData.rank).toBeTruthy();
|
|
56
51
|
expect(newMeta.queen === HaileiMetaData.queen).toBeTruthy();
|
|
@@ -68,13 +63,13 @@ describe('class DYOToolsComponentWithMeta', () => {
|
|
|
68
63
|
});
|
|
69
64
|
|
|
70
65
|
test('return all meta', () => {
|
|
71
|
-
componentWithMetaTest
|
|
66
|
+
componentWithMetaTest = new DTComponentWithMetaTest(IDTest, KeyTest, { ...HaileiMetaData });
|
|
72
67
|
|
|
73
68
|
expect(componentWithMetaTest.getManyMeta()).toStrictEqual(HaileiMetaData);
|
|
74
69
|
});
|
|
75
70
|
|
|
76
71
|
test('return meta by keys', () => {
|
|
77
|
-
componentWithMetaTest
|
|
72
|
+
componentWithMetaTest = new DTComponentWithMetaTest(IDTest, KeyTest, { ...HaileiMetaData });
|
|
78
73
|
const keys: Array<keyof IMetaDataTest> = ['name', 'kd', 'queen'];
|
|
79
74
|
|
|
80
75
|
expect(componentWithMetaTest.getManyMeta(keys)).toStrictEqual({
|
|
@@ -85,7 +80,7 @@ describe('class DYOToolsComponentWithMeta', () => {
|
|
|
85
80
|
});
|
|
86
81
|
|
|
87
82
|
test('return meta by keys - unexisting keys', () => {
|
|
88
|
-
componentWithMetaTest
|
|
83
|
+
componentWithMetaTest = new DTComponentWithMetaTest(IDTest, KeyTest, { ...YssaliaMetaData });
|
|
89
84
|
const keys: Array<keyof IMetaDataTest> = ['name', 'rank', 'tribes'];
|
|
90
85
|
|
|
91
86
|
expect(componentWithMetaTest.getManyMeta(keys)).toStrictEqual({
|
|
@@ -96,7 +91,7 @@ describe('class DYOToolsComponentWithMeta', () => {
|
|
|
96
91
|
|
|
97
92
|
describe('setManyMeta()', () => {
|
|
98
93
|
test('set new values', () => {
|
|
99
|
-
componentWithMetaTest
|
|
94
|
+
componentWithMetaTest = new DTComponentWithMetaTest(IDTest, KeyTest, { ...HaileiMetaData });
|
|
100
95
|
const setValues: Partial<IMetaDataTest> = {
|
|
101
96
|
name: MeldrineMetaData.name,
|
|
102
97
|
queen: MeldrineMetaData.queen,
|
|
@@ -105,7 +100,7 @@ describe('class DYOToolsComponentWithMeta', () => {
|
|
|
105
100
|
|
|
106
101
|
componentWithMetaTest.setManyMeta(setValues);
|
|
107
102
|
|
|
108
|
-
const newMeta = componentWithMetaTest.
|
|
103
|
+
const newMeta = componentWithMetaTest._getMeta();
|
|
109
104
|
expect(newMeta.name === MeldrineMetaData.name).toBeTruthy();
|
|
110
105
|
expect(newMeta.queen === MeldrineMetaData.queen).toBeTruthy();
|
|
111
106
|
expect(newMeta.kd[0] === HaileiMetaData.kd[0]).toBeTruthy();
|
|
@@ -114,11 +109,21 @@ describe('class DYOToolsComponentWithMeta', () => {
|
|
|
114
109
|
});
|
|
115
110
|
|
|
116
111
|
test('set empty new values (keep former meta)', () => {
|
|
117
|
-
componentWithMetaTest
|
|
112
|
+
componentWithMetaTest = new DTComponentWithMetaTest(IDTest, KeyTest, { ...HaileiMetaData });
|
|
118
113
|
|
|
119
114
|
componentWithMetaTest.setManyMeta({});
|
|
120
115
|
|
|
121
|
-
expect(componentWithMetaTest.
|
|
116
|
+
expect(componentWithMetaTest._getMeta()).toStrictEqual(HaileiMetaData);
|
|
122
117
|
});
|
|
123
118
|
});
|
|
119
|
+
|
|
120
|
+
// describe('toDIXObject()', () => {
|
|
121
|
+
// test('return parent and meta', () => {
|
|
122
|
+
// componentWithMetaTest = new DTComponentWithMetaTest(IDTest, KeyTest, { ...HaileiMetaData });
|
|
123
|
+
//
|
|
124
|
+
// const dixObject = componentWithMetaTest.toDIXObject();
|
|
125
|
+
//
|
|
126
|
+
// expect(dixObject).toStrictEqual(ToDIXObjectTest);
|
|
127
|
+
// });
|
|
128
|
+
// });
|
|
124
129
|
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {DTBunch, DTElement} from '../../src';
|
|
2
2
|
import {IMetaDataTest} from './DTComponentWithMeta.double';
|
|
3
|
+
import {DTElementToObject} from "../../src/types";
|
|
4
|
+
import {DTBunchStub} from "./DTBunch.double";
|
|
3
5
|
|
|
4
6
|
/** ****************** STUB PROPERTIES CONSTANTS
|
|
5
7
|
* Fixed properties to use with double classes, avoid auto generated and easy checking on test
|
|
@@ -13,91 +15,68 @@ export const DomainTest = 'DTElement-domain-test';
|
|
|
13
15
|
export const HaileiIdTest = 'DTElement-id-Hailei';
|
|
14
16
|
export const HaileiKeyTest = 'DTElement-key-Hailei';
|
|
15
17
|
export const HaileiToObjectTest = { id: 'DTElement-id-Hailei', key: 'DTElement-key-Hailei', type: 'element' };
|
|
18
|
+
|
|
16
19
|
export const MeldrineIdTest = 'DTElement-id-Meldrine';
|
|
17
20
|
export const MeldrineKeyTest = 'DTElement-key-Meldrine';
|
|
18
21
|
export const MeldrineToObjectTest = { id: 'DTElement-id-Meldrine', key: 'DTElement-key-Meldrine', type: 'element' };
|
|
22
|
+
|
|
19
23
|
export const MaydenaIdTest = 'DTElement-id-Maydena';
|
|
20
24
|
export const MaydenaKeyTest = 'DTElement-key-Maydena';
|
|
21
25
|
export const MaydenaToObjectTest = { id: 'DTElement-id-Maydena', key: 'DTElement-key-Maydena', type: 'element' };
|
|
26
|
+
|
|
22
27
|
export const IldressIdTest = 'DTElement-id-Ildress';
|
|
23
28
|
export const IldressKeyTest = 'DTElement-key-Ildress';
|
|
24
29
|
export const IldressToObjectTest = { id: 'DTElement-id-Ildress', key: 'DTElement-key-Ildress', type: 'element' };
|
|
30
|
+
|
|
25
31
|
export const YssaliaIdTest = 'DTElement-id-Yssalia';
|
|
26
32
|
export const YssaliaKeyTest = 'DTElement-key-Yssalia';
|
|
27
33
|
export const YssaliaToObjectTest = { id: 'DTElement-id-Yssalia', key: 'DTElement-key-Yssalia', type: 'element' };
|
|
28
34
|
|
|
35
|
+
|
|
29
36
|
/** ****************** HELPER TEST CLASS
|
|
30
37
|
* Helper test class, inherits the main component
|
|
31
38
|
* Providing methods to property access and other facilities, in order to avoid using class methods
|
|
32
39
|
* **** */
|
|
33
40
|
export class DTElementTest extends DTElement<IMetaDataTest> {
|
|
34
|
-
th_get_id(): string {
|
|
35
|
-
return this._id;
|
|
36
|
-
}
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
constructor(
|
|
43
|
+
id: string = IDTest,
|
|
44
|
+
key: string = KeyTest,
|
|
45
|
+
container: DTBunchStub | undefined = undefined,
|
|
46
|
+
domain?: string,
|
|
47
|
+
) {
|
|
48
|
+
super(key);
|
|
39
49
|
this._id = id;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
th_get_key(): string {
|
|
43
|
-
return this._key;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
th_set_key(key: string): void {
|
|
47
|
-
this._key = key;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
th_get_componentType(): string {
|
|
51
|
-
return this._componentType;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
th_get_domain(): string {
|
|
55
|
-
return this._domain;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
th_set_domain(domain: string): void {
|
|
50
|
+
this._container = container as DTBunch;
|
|
59
51
|
this._domain = domain;
|
|
60
52
|
}
|
|
61
|
-
|
|
62
|
-
th_get_owner(): string {
|
|
63
|
-
return this._owner;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
th_set_owner(owner: string): void {
|
|
67
|
-
this._owner = owner;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
th_set_meta(meta: IMetaDataTest): void {
|
|
71
|
-
this._meta = meta;
|
|
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
|
-
}
|
|
81
53
|
}
|
|
82
54
|
/** ****************** STUB CLASS
|
|
83
55
|
* Stub class, for using in other component
|
|
84
56
|
* **** */
|
|
85
57
|
export class DTElementStub extends DTElement<IMetaDataTest> {
|
|
86
58
|
public parentIndex: number;
|
|
87
|
-
|
|
88
|
-
|
|
59
|
+
public mockedToObject: DTElementToObject<IMetaDataTest>;
|
|
60
|
+
|
|
61
|
+
constructor(
|
|
62
|
+
index = 0,
|
|
63
|
+
id: string = IDTest,
|
|
64
|
+
key: string = KeyTest,
|
|
65
|
+
meta: Partial<IMetaDataTest> = {},
|
|
66
|
+
owner: string | undefined = undefined,
|
|
67
|
+
toObject: DTElementToObject<IMetaDataTest> = HaileiToObjectTest,
|
|
68
|
+
) {
|
|
89
69
|
super();
|
|
90
|
-
this._id =
|
|
91
|
-
this._key =
|
|
70
|
+
this._id = id;
|
|
71
|
+
this._key = key;
|
|
72
|
+
this._meta = meta;
|
|
73
|
+
this._owner = owner;
|
|
92
74
|
this.parentIndex = index;
|
|
75
|
+
this.mockedToObject = toObject;
|
|
93
76
|
}
|
|
94
77
|
|
|
95
|
-
|
|
96
|
-
return
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
getKey(): string {
|
|
100
|
-
return KeyTest;
|
|
78
|
+
toObject(): DTElementToObject<IMetaDataTest> {
|
|
79
|
+
return this.mockedToObject;
|
|
101
80
|
}
|
|
102
81
|
}
|
|
103
82
|
export class DTElementStubExtended extends DTElementStub {
|