dyo-tools 0.4.0 → 0.4.1
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/index.d.ts → index.d.ts} +1 -0
- package/{dist/index.d.ts.map → index.d.ts.map} +1 -1
- package/{dist/index.js → index.js} +1 -0
- package/package.json +6 -56
- package/.c8rc.json +0 -4
- package/.eslintignore +0 -2
- package/.eslintrc.json +0 -47
- package/Makefile +0 -34
- package/README.md +0 -0
- package/babel.config.js +0 -1
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -29
- package/docs/assets/main.js +0 -59
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1414
- package/docs/index.html +0 -1
- package/integration/data/components/DTHero.ts +0 -42
- package/integration/data/components/DTHeroManager.ts +0 -11
- package/integration/data/components/DTHeroPlayZone.ts +0 -6
- package/integration/data/components/DTHeroPlayerHand.ts +0 -11
- package/integration/data/components/index.ts +0 -5
- package/integration/data/in/heroIn.helper.ts +0 -8
- package/integration/data/in/playerIn.helper.ts +0 -13
- package/integration/data/out/heroOut.helper.ts +0 -48
- package/integration/endings/synchronisation.ending.ts +0 -25
- package/integration/scenes/drawCard.scene.ts +0 -31
- package/integration/scenes/empty.scene.ts +0 -6
- package/integration/scenes/playCard.scene.ts +0 -23
- package/integration/scenes/playerLeave.scene.ts +0 -33
- package/integration/stages/baseDix.stage.ts +0 -137
- package/integration/stages/syncDix.stage.ts +0 -36
- package/integration/tests/scenario1.spec.ts +0 -55
- package/integration/types/index.ts +0 -24
- package/jest-integration.config.ts +0 -25
- package/jest.config.ts +0 -26
- package/src/constants.ts +0 -87
- package/src/core/DTAction.ts +0 -54
- package/src/core/DTBunch.ts +0 -531
- package/src/core/DTComponent.ts +0 -258
- package/src/core/DTComponentPhysical.ts +0 -88
- package/src/core/DTComponentWithMeta.ts +0 -98
- package/src/core/DTElement.ts +0 -111
- package/src/core/DTError.ts +0 -78
- package/src/core/DTManager.ts +0 -555
- package/src/core/DTMaster.ts +0 -366
- package/src/core/DTModule.ts +0 -96
- package/src/index.ts +0 -17
- package/src/libs/DYOFinder.ts +0 -175
- package/src/libs/dix/DIXModule.module.ts +0 -98
- package/src/libs/player/DTPlayer.element.ts +0 -9
- package/src/libs/player/DTPlayer.manager.ts +0 -70
- package/src/types/core.ts +0 -204
- package/src/types/index.ts +0 -2
- package/src/types/player.ts +0 -5
- package/test/core/DTAction.double.ts +0 -62
- package/test/core/DTAction.spec.ts +0 -68
- package/test/core/DTBunch.double.ts +0 -175
- package/test/core/DTBunch.spec.ts +0 -822
- package/test/core/DTComponent.double.ts +0 -179
- package/test/core/DTComponent.spec.ts +0 -297
- package/test/core/DTComponentPhysical.double.ts +0 -62
- package/test/core/DTComponentPhysical.spec.ts +0 -81
- package/test/core/DTComponentWithMeta.double.ts +0 -122
- package/test/core/DTComponentWithMeta.spec.ts +0 -129
- package/test/core/DTElement.double.ts +0 -142
- package/test/core/DTElement.spec.ts +0 -123
- package/test/core/DTError.double.ts +0 -57
- package/test/core/DTError.spec.ts +0 -78
- package/test/core/DTManager.double.ts +0 -149
- package/test/core/DTManager.spec.ts +0 -874
- package/test/core/DTMaster.double.ts +0 -117
- package/test/core/DTMaster.spec.ts +0 -537
- package/test/core/DTModule.double.ts +0 -67
- package/test/core/DTModule.spec.ts +0 -124
- package/test/core/copy.spec.ts +0 -222
- package/test/libs/DYOFinder.double.ts +0 -152
- package/test/libs/DYOFinder.spec.ts +0 -194
- package/test/libs/player/DTPlayer.element.double.ts +0 -55
- package/test/libs/player/DTPlayer.element.spec.ts +0 -28
- package/test/libs/player/DTPlayer.manager.double.ts +0 -92
- package/test/libs/player/DTPlayer.manager.spec.ts +0 -178
- package/tsconfig.dev.json +0 -19
- package/tsconfig.json +0 -18
- /package/{dist/constants.d.ts → constants.d.ts} +0 -0
- /package/{dist/constants.d.ts.map → constants.d.ts.map} +0 -0
- /package/{dist/constants.js → constants.js} +0 -0
- /package/{dist/constants.js.map → constants.js.map} +0 -0
- /package/{dist/core → core}/DTAction.d.ts +0 -0
- /package/{dist/core → core}/DTAction.d.ts.map +0 -0
- /package/{dist/core → core}/DTAction.js +0 -0
- /package/{dist/core → core}/DTAction.js.map +0 -0
- /package/{dist/core → core}/DTBunch.d.ts +0 -0
- /package/{dist/core → core}/DTBunch.d.ts.map +0 -0
- /package/{dist/core → core}/DTBunch.js +0 -0
- /package/{dist/core → core}/DTBunch.js.map +0 -0
- /package/{dist/core → core}/DTComponent.d.ts +0 -0
- /package/{dist/core → core}/DTComponent.d.ts.map +0 -0
- /package/{dist/core → core}/DTComponent.js +0 -0
- /package/{dist/core → core}/DTComponent.js.map +0 -0
- /package/{dist/core → core}/DTComponentPhysical.d.ts +0 -0
- /package/{dist/core → core}/DTComponentPhysical.d.ts.map +0 -0
- /package/{dist/core → core}/DTComponentPhysical.js +0 -0
- /package/{dist/core → core}/DTComponentPhysical.js.map +0 -0
- /package/{dist/core → core}/DTComponentWithMeta.d.ts +0 -0
- /package/{dist/core → core}/DTComponentWithMeta.d.ts.map +0 -0
- /package/{dist/core → core}/DTComponentWithMeta.js +0 -0
- /package/{dist/core → core}/DTComponentWithMeta.js.map +0 -0
- /package/{dist/core → core}/DTElement.d.ts +0 -0
- /package/{dist/core → core}/DTElement.d.ts.map +0 -0
- /package/{dist/core → core}/DTElement.js +0 -0
- /package/{dist/core → core}/DTElement.js.map +0 -0
- /package/{dist/core → core}/DTError.d.ts +0 -0
- /package/{dist/core → core}/DTError.d.ts.map +0 -0
- /package/{dist/core → core}/DTError.js +0 -0
- /package/{dist/core → core}/DTError.js.map +0 -0
- /package/{dist/core → core}/DTManager.d.ts +0 -0
- /package/{dist/core → core}/DTManager.d.ts.map +0 -0
- /package/{dist/core → core}/DTManager.js +0 -0
- /package/{dist/core → core}/DTManager.js.map +0 -0
- /package/{dist/core → core}/DTMaster.d.ts +0 -0
- /package/{dist/core → core}/DTMaster.d.ts.map +0 -0
- /package/{dist/core → core}/DTMaster.js +0 -0
- /package/{dist/core → core}/DTMaster.js.map +0 -0
- /package/{dist/core → core}/DTModule.d.ts +0 -0
- /package/{dist/core → core}/DTModule.d.ts.map +0 -0
- /package/{dist/core → core}/DTModule.js +0 -0
- /package/{dist/core → core}/DTModule.js.map +0 -0
- /package/{dist/index.js.map → index.js.map} +0 -0
- /package/{dist/libs → libs}/DYOFinder.d.ts +0 -0
- /package/{dist/libs → libs}/DYOFinder.d.ts.map +0 -0
- /package/{dist/libs → libs}/DYOFinder.js +0 -0
- /package/{dist/libs → libs}/DYOFinder.js.map +0 -0
- /package/{dist/libs → libs}/dix/DIXModule.module.d.ts +0 -0
- /package/{dist/libs → libs}/dix/DIXModule.module.d.ts.map +0 -0
- /package/{dist/libs → libs}/dix/DIXModule.module.js +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.element.d.ts +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.element.d.ts.map +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.element.js +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.element.js.map +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.manager.d.ts +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.manager.d.ts.map +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.manager.js +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.manager.js.map +0 -0
- /package/{dist/tsconfig.dev.tsbuildinfo → tsconfig.dev.tsbuildinfo} +0 -0
- /package/{dist/tsconfig.tsbuildinfo → tsconfig.tsbuildinfo} +0 -0
- /package/{dist/types → types}/core.d.ts +0 -0
- /package/{dist/types → types}/core.d.ts.map +0 -0
- /package/{dist/types → types}/core.js +0 -0
- /package/{dist/types → types}/core.js.map +0 -0
- /package/{dist/types → types}/index.d.ts +0 -0
- /package/{dist/types → types}/index.d.ts.map +0 -0
- /package/{dist/types → types}/index.js +0 -0
- /package/{dist/types → types}/index.js.map +0 -0
- /package/{dist/types → types}/player.d.ts +0 -0
- /package/{dist/types → types}/player.d.ts.map +0 -0
- /package/{dist/types → types}/player.js +0 -0
- /package/{dist/types → types}/player.js.map +0 -0
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import {DTComponentWithMeta} from '../../src';
|
|
2
|
-
import {DTAcceptedMetaData} from "../../src/types";
|
|
3
|
-
|
|
4
|
-
/******************** STUB PROPERTIES CONSTANTS
|
|
5
|
-
* Fixed properties to use with double classes, avoid auto generated and easy checking on test
|
|
6
|
-
* *****/
|
|
7
|
-
// Test meta data interface
|
|
8
|
-
export interface IMetaDataTest extends DTAcceptedMetaData {
|
|
9
|
-
name: string,
|
|
10
|
-
queen: boolean,
|
|
11
|
-
kd: number[],
|
|
12
|
-
rank?: number,
|
|
13
|
-
tribes?: string[]
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Global properties
|
|
17
|
-
export const IDTest = "DTComponentWithMeta-id-1234567";
|
|
18
|
-
export const KeyTest = "DTComponentWithMeta-key-1234567";
|
|
19
|
-
export const ComponentTypeTest = 'DTComponentWithMeta-componentType-test';
|
|
20
|
-
export const ToObjectTest = { type: "DTComponentWithMeta-test-toObject" };
|
|
21
|
-
export const ToStringTest = "DTComponentWithMeta-test-toString";
|
|
22
|
-
|
|
23
|
-
// Specific components tests meta-data
|
|
24
|
-
export const HaileiMetaData: IMetaDataTest = {
|
|
25
|
-
name: 'Hailei Dorcan Kazan',
|
|
26
|
-
queen: true,
|
|
27
|
-
kd: [47, 1],
|
|
28
|
-
rank: 1,
|
|
29
|
-
tribes: ['Peuple de Salta', 'Fils de Salta', 'Peuple Kanti'],
|
|
30
|
-
};
|
|
31
|
-
export const MeldrineMetaData: IMetaDataTest = {
|
|
32
|
-
name: 'Meldrine Goldmane',
|
|
33
|
-
queen: false,
|
|
34
|
-
kd: [53, 0],
|
|
35
|
-
rank: 2,
|
|
36
|
-
tribes: ['Lodaniens'],
|
|
37
|
-
};
|
|
38
|
-
export const MaydenaMetaData: IMetaDataTest = {
|
|
39
|
-
name: "Maydena 'Intan Kazan",
|
|
40
|
-
queen: true,
|
|
41
|
-
kd: [29, 0],
|
|
42
|
-
tribes: ['Exil rouge', 'Désolation'],
|
|
43
|
-
};
|
|
44
|
-
export const IldressMetaData: IMetaDataTest = {
|
|
45
|
-
name: 'Electel Ildress',
|
|
46
|
-
queen: false,
|
|
47
|
-
kd: [19, 1],
|
|
48
|
-
rank: 3,
|
|
49
|
-
};
|
|
50
|
-
export const YssaliaMetaData: IMetaDataTest = {
|
|
51
|
-
name: 'Yssalia du Gillit',
|
|
52
|
-
queen: true,
|
|
53
|
-
kd: [23, 0],
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// Player default value
|
|
57
|
-
export const PlayerMetaData: IMetaDataTest = {
|
|
58
|
-
name: 'Llhôonn',
|
|
59
|
-
queen: true,
|
|
60
|
-
kd: [0, 0],
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Bunch default value
|
|
64
|
-
export const BunchMetaData: IMetaDataTest = {
|
|
65
|
-
name: 'Elementary Pentacle',
|
|
66
|
-
queen: true,
|
|
67
|
-
kd: [117, 3],
|
|
68
|
-
};
|
|
69
|
-
|
|
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
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/******************** HELPER TEST CLASS
|
|
86
|
-
* Helper test class, inherits the main component
|
|
87
|
-
* Providing methods to property access and other facilities, in order to avoid using class methods
|
|
88
|
-
* *****/
|
|
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> {
|
|
103
|
-
return this._meta;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
copy(): DTComponentWithMeta<IMetaDataTest> {
|
|
107
|
-
return this;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
toObject(): any {
|
|
111
|
-
return ToObjectTest;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
toString(): string {
|
|
115
|
-
return ToStringTest;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/******************** HELPER METHODS
|
|
120
|
-
* Additional helper methods to use with testing
|
|
121
|
-
* *****/
|
|
122
|
-
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import {afterEach, beforeEach, describe, expect, jest, test,} from '@jest/globals';
|
|
2
|
-
import {
|
|
3
|
-
DTComponentWithMetaTest,
|
|
4
|
-
HaileiMetaData,
|
|
5
|
-
IDTest,
|
|
6
|
-
IMetaDataTest,
|
|
7
|
-
KeyTest,
|
|
8
|
-
MeldrineMetaData,
|
|
9
|
-
YssaliaMetaData
|
|
10
|
-
} from './DTComponentWithMeta.double';
|
|
11
|
-
import {DTComponent, DTComponentWithMeta} from "../../src";
|
|
12
|
-
|
|
13
|
-
/************************* TESTS SUITES *******************************/
|
|
14
|
-
describe('class DTComponentWithMeta', () => {
|
|
15
|
-
let componentWithMetaTest: DTComponentWithMetaTest;
|
|
16
|
-
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
componentWithMetaTest = new DTComponentWithMetaTest();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
afterEach(() => {
|
|
22
|
-
jest.resetAllMocks();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('inheritance', () => {
|
|
26
|
-
test('check good inheritance for class', () => {
|
|
27
|
-
expect(DTComponentWithMeta.prototype instanceof DTComponent).toBeTruthy();
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe('getMeta()', () => {
|
|
32
|
-
test('return undefined if meta is empty', () => {
|
|
33
|
-
expect(componentWithMetaTest.getMeta('name')).toBeUndefined();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('return one meta by key', () => {
|
|
37
|
-
componentWithMetaTest = new DTComponentWithMetaTest(IDTest, KeyTest, { ...HaileiMetaData });
|
|
38
|
-
|
|
39
|
-
expect(componentWithMetaTest.getMeta('name')).toBe(HaileiMetaData.name);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe('setMeta()', () => {
|
|
44
|
-
test('set a new value for a meta', () => {
|
|
45
|
-
componentWithMetaTest = new DTComponentWithMetaTest(IDTest, KeyTest, { ...HaileiMetaData });
|
|
46
|
-
componentWithMetaTest.setMeta('name', MeldrineMetaData.name);
|
|
47
|
-
|
|
48
|
-
const newMeta = componentWithMetaTest._getMeta();
|
|
49
|
-
expect(newMeta.name === MeldrineMetaData.name).toBeTruthy();
|
|
50
|
-
expect(newMeta.rank === HaileiMetaData.rank).toBeTruthy();
|
|
51
|
-
expect(newMeta.queen === HaileiMetaData.queen).toBeTruthy();
|
|
52
|
-
expect(newMeta.kd[0] === HaileiMetaData.kd[0]).toBeTruthy();
|
|
53
|
-
expect(newMeta.tribes[0] === HaileiMetaData.tribes[0]).toBeTruthy();
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe('getManyMeta()', () => {
|
|
58
|
-
test('return empty object meta by default', () => {
|
|
59
|
-
const keys: Array<keyof IMetaDataTest> = ['name', 'rank', 'tribes'];
|
|
60
|
-
|
|
61
|
-
expect(componentWithMetaTest.getManyMeta()).toStrictEqual({});
|
|
62
|
-
expect(componentWithMetaTest.getManyMeta(keys)).toStrictEqual({});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test('return all meta', () => {
|
|
66
|
-
componentWithMetaTest = new DTComponentWithMetaTest(IDTest, KeyTest, { ...HaileiMetaData });
|
|
67
|
-
|
|
68
|
-
expect(componentWithMetaTest.getManyMeta()).toStrictEqual(HaileiMetaData);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test('return meta by keys', () => {
|
|
72
|
-
componentWithMetaTest = new DTComponentWithMetaTest(IDTest, KeyTest, { ...HaileiMetaData });
|
|
73
|
-
const keys: Array<keyof IMetaDataTest> = ['name', 'kd', 'queen'];
|
|
74
|
-
|
|
75
|
-
expect(componentWithMetaTest.getManyMeta(keys)).toStrictEqual({
|
|
76
|
-
name: HaileiMetaData.name,
|
|
77
|
-
kd: HaileiMetaData.kd,
|
|
78
|
-
queen: HaileiMetaData.queen,
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test('return meta by keys - unexisting keys', () => {
|
|
83
|
-
componentWithMetaTest = new DTComponentWithMetaTest(IDTest, KeyTest, { ...YssaliaMetaData });
|
|
84
|
-
const keys: Array<keyof IMetaDataTest> = ['name', 'rank', 'tribes'];
|
|
85
|
-
|
|
86
|
-
expect(componentWithMetaTest.getManyMeta(keys)).toStrictEqual({
|
|
87
|
-
name: YssaliaMetaData.name,
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
describe('setManyMeta()', () => {
|
|
93
|
-
test('set new values', () => {
|
|
94
|
-
componentWithMetaTest = new DTComponentWithMetaTest(IDTest, KeyTest, { ...HaileiMetaData });
|
|
95
|
-
const setValues: Partial<IMetaDataTest> = {
|
|
96
|
-
name: MeldrineMetaData.name,
|
|
97
|
-
queen: MeldrineMetaData.queen,
|
|
98
|
-
rank: MeldrineMetaData.rank,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
componentWithMetaTest.setManyMeta(setValues);
|
|
102
|
-
|
|
103
|
-
const newMeta = componentWithMetaTest._getMeta();
|
|
104
|
-
expect(newMeta.name === MeldrineMetaData.name).toBeTruthy();
|
|
105
|
-
expect(newMeta.queen === MeldrineMetaData.queen).toBeTruthy();
|
|
106
|
-
expect(newMeta.kd[0] === HaileiMetaData.kd[0]).toBeTruthy();
|
|
107
|
-
expect(newMeta.rank === MeldrineMetaData.rank).toBeTruthy();
|
|
108
|
-
expect(newMeta.tribes[0] === HaileiMetaData.tribes[0]).toBeTruthy();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
test('set empty new values (keep former meta)', () => {
|
|
112
|
-
componentWithMetaTest = new DTComponentWithMetaTest(IDTest, KeyTest, { ...HaileiMetaData });
|
|
113
|
-
|
|
114
|
-
componentWithMetaTest.setManyMeta({});
|
|
115
|
-
|
|
116
|
-
expect(componentWithMetaTest._getMeta()).toStrictEqual(HaileiMetaData);
|
|
117
|
-
});
|
|
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
|
-
// });
|
|
129
|
-
});
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import {DTBunch, DTElement} from '../../src';
|
|
2
|
-
import {IMetaDataTest} from './DTComponentWithMeta.double';
|
|
3
|
-
import {DTElementToObject} from "../../src/types";
|
|
4
|
-
import {DTBunchStub} from "./DTBunch.double";
|
|
5
|
-
|
|
6
|
-
/** ****************** STUB PROPERTIES CONSTANTS
|
|
7
|
-
* Fixed properties to use with double classes, avoid auto generated and easy checking on test
|
|
8
|
-
* **** */
|
|
9
|
-
// Global constants
|
|
10
|
-
export const IDTest = 'DTElement-id-1234567';
|
|
11
|
-
export const KeyTest = 'DTElement-key-1234567';
|
|
12
|
-
export const DomainTest = 'DTElement-domain-test';
|
|
13
|
-
|
|
14
|
-
// Specific elements constants
|
|
15
|
-
export const HaileiIdTest = 'DTElement-id-Hailei';
|
|
16
|
-
export const HaileiKeyTest = 'DTElement-key-Hailei';
|
|
17
|
-
export const HaileiToObjectTest = { id: 'DTElement-id-Hailei', key: 'DTElement-key-Hailei', type: 'element' };
|
|
18
|
-
|
|
19
|
-
export const MeldrineIdTest = 'DTElement-id-Meldrine';
|
|
20
|
-
export const MeldrineKeyTest = 'DTElement-key-Meldrine';
|
|
21
|
-
export const MeldrineToObjectTest = { id: 'DTElement-id-Meldrine', key: 'DTElement-key-Meldrine', type: 'element' };
|
|
22
|
-
|
|
23
|
-
export const MaydenaIdTest = 'DTElement-id-Maydena';
|
|
24
|
-
export const MaydenaKeyTest = 'DTElement-key-Maydena';
|
|
25
|
-
export const MaydenaToObjectTest = { id: 'DTElement-id-Maydena', key: 'DTElement-key-Maydena', type: 'element' };
|
|
26
|
-
|
|
27
|
-
export const IldressIdTest = 'DTElement-id-Ildress';
|
|
28
|
-
export const IldressKeyTest = 'DTElement-key-Ildress';
|
|
29
|
-
export const IldressToObjectTest = { id: 'DTElement-id-Ildress', key: 'DTElement-key-Ildress', type: 'element' };
|
|
30
|
-
|
|
31
|
-
export const YssaliaIdTest = 'DTElement-id-Yssalia';
|
|
32
|
-
export const YssaliaKeyTest = 'DTElement-key-Yssalia';
|
|
33
|
-
export const YssaliaToObjectTest = { id: 'DTElement-id-Yssalia', key: 'DTElement-key-Yssalia', type: 'element' };
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/** ****************** HELPER TEST CLASS
|
|
37
|
-
* Helper test class, inherits the main component
|
|
38
|
-
* Providing methods to property access and other facilities, in order to avoid using class methods
|
|
39
|
-
* **** */
|
|
40
|
-
export class DTElementTest extends DTElement<IMetaDataTest> {
|
|
41
|
-
|
|
42
|
-
constructor(
|
|
43
|
-
id: string = IDTest,
|
|
44
|
-
key: string = KeyTest,
|
|
45
|
-
container: DTBunchStub | undefined = undefined,
|
|
46
|
-
domain?: string,
|
|
47
|
-
) {
|
|
48
|
-
super(key);
|
|
49
|
-
this._id = id;
|
|
50
|
-
this._container = container as DTBunch;
|
|
51
|
-
this._domain = domain;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/** ****************** STUB CLASS
|
|
55
|
-
* Stub class, for using in other component
|
|
56
|
-
* **** */
|
|
57
|
-
export class DTElementStub extends DTElement<IMetaDataTest> {
|
|
58
|
-
public parentIndex: number;
|
|
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
|
-
) {
|
|
69
|
-
super();
|
|
70
|
-
this._id = id;
|
|
71
|
-
this._key = key;
|
|
72
|
-
this._meta = meta;
|
|
73
|
-
this._owner = owner;
|
|
74
|
-
this.parentIndex = index;
|
|
75
|
-
this.mockedToObject = toObject;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
toObject(): DTElementToObject<IMetaDataTest> {
|
|
79
|
-
return this.mockedToObject;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
export class DTElementStubExtended extends DTElementStub {
|
|
83
|
-
private propString: string;
|
|
84
|
-
|
|
85
|
-
private propArray: string[];
|
|
86
|
-
|
|
87
|
-
private propNumber: number;
|
|
88
|
-
|
|
89
|
-
private propBoolean: boolean;
|
|
90
|
-
|
|
91
|
-
private propObject: Record<string, unknown>;
|
|
92
|
-
|
|
93
|
-
private propMeta: Record<string, unknown>;
|
|
94
|
-
|
|
95
|
-
getPropString(): string {
|
|
96
|
-
return this.propString;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
setPropString(propString: string): void {
|
|
100
|
-
this.propString = propString;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
getPropArray(): string[] {
|
|
104
|
-
return this.propArray;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
setPropArray(propArray: string[]): void {
|
|
108
|
-
this.propArray = propArray;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
getPropNumber(): number {
|
|
112
|
-
return this.propNumber;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
setPropNumber(propNumber: number): void {
|
|
116
|
-
this.propNumber = propNumber;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
getPropBoolean(): boolean {
|
|
120
|
-
return this.propBoolean;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
setPropBoolean(propBoolean: boolean): void {
|
|
124
|
-
this.propBoolean = propBoolean;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
getPropObject(): Record<string, unknown> {
|
|
128
|
-
return this.propObject;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
setPropObject(propObject: Record<string, unknown>): void {
|
|
132
|
-
this.propObject = propObject;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
getPropMeta(): Record<string, unknown> {
|
|
136
|
-
return this.propMeta;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
setPropMeta(propMeta: Record<string, unknown>): void {
|
|
140
|
-
this.propMeta = propMeta;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
|
2
|
-
import {DomainTest, DTElementTest, IDTest, KeyTest} from './DTElement.double';
|
|
3
|
-
import {MeldrineMetaData} from './DTComponentWithMeta.double';
|
|
4
|
-
import {DTBunch, DTComponentPhysical, DTElement} from "../../src";
|
|
5
|
-
import {OwnerTest} from "./DTComponentPhysical.double";
|
|
6
|
-
import {DTBunchStub, IDTest as bunchIdTest} from "./DTBunch.double";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/************************* TESTS SUITES *******************************/
|
|
10
|
-
describe('class DTElement', () => {
|
|
11
|
-
let elementTest: DTElementTest;
|
|
12
|
-
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
elementTest = new DTElementTest();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
afterEach(() => {
|
|
18
|
-
jest.resetAllMocks();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
describe('inheritance', () => {
|
|
22
|
-
test('check good inheritance for class', () => {
|
|
23
|
-
expect(DTElement.prototype instanceof DTComponentPhysical).toBeTruthy();
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
describe('_componentType', () => {
|
|
28
|
-
test('componentType must be "element"', () => {
|
|
29
|
-
expect(elementTest.getComponentType()).toBe('element');
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe('getContainer()', () => {
|
|
34
|
-
test('return undefined if no container - default case', () => {
|
|
35
|
-
expect(elementTest.getContainer()).toBeUndefined();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('return container', () => {
|
|
39
|
-
const container = new DTBunchStub();
|
|
40
|
-
elementTest = new DTElementTest(IDTest, KeyTest, container);
|
|
41
|
-
|
|
42
|
-
expect(elementTest.getContainer()).toBeDefined();
|
|
43
|
-
expect(elementTest.getContainer().getId()).toStrictEqual(bunchIdTest);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe('setContainer()', () => {
|
|
48
|
-
test('set a new container for element', () => {
|
|
49
|
-
const container = new DTBunchStub();
|
|
50
|
-
|
|
51
|
-
elementTest.setContainer(container as DTBunch);
|
|
52
|
-
|
|
53
|
-
expect(elementTest.getContainer()).toBeDefined();
|
|
54
|
-
expect(elementTest.getContainer().getId()).toStrictEqual(bunchIdTest);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe('removeContainer()', () => {
|
|
59
|
-
test('remove the current container', () => {
|
|
60
|
-
const bunchContainer = new DTBunchStub();
|
|
61
|
-
elementTest = new DTElementTest(IDTest, KeyTest, bunchContainer);
|
|
62
|
-
|
|
63
|
-
elementTest.removeContainer();
|
|
64
|
-
expect(elementTest.getContainer()).toBeUndefined();
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe('toObject()', () => {
|
|
69
|
-
|
|
70
|
-
test('toObject output standard', () => {
|
|
71
|
-
const toObjectElement = elementTest.toObject();
|
|
72
|
-
|
|
73
|
-
expect(Object.keys(toObjectElement)).toStrictEqual(['id', 'key', 'type']);
|
|
74
|
-
expect(toObjectElement.id).toBe(IDTest);
|
|
75
|
-
expect(toObjectElement.key).toBe(KeyTest);
|
|
76
|
-
expect(toObjectElement.type).toBe('element');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test('toObject output standard with owner', () => {
|
|
80
|
-
elementTest.setOwner(OwnerTest);
|
|
81
|
-
|
|
82
|
-
const toObjectElement = elementTest.toObject();
|
|
83
|
-
|
|
84
|
-
expect(Object.keys(toObjectElement)).toStrictEqual(['id', 'key', 'type', 'owner']);
|
|
85
|
-
expect(toObjectElement.owner).toBe(OwnerTest);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test('toObject output standard with owner and meta', () => {
|
|
89
|
-
elementTest.setOwner(OwnerTest);
|
|
90
|
-
elementTest.setManyMeta(MeldrineMetaData);
|
|
91
|
-
|
|
92
|
-
const toObjectElement = elementTest.toObject();
|
|
93
|
-
|
|
94
|
-
expect(Object.keys(toObjectElement)).toStrictEqual(['id', 'key', 'type', 'owner', 'meta']);
|
|
95
|
-
expect(toObjectElement.meta).toStrictEqual(MeldrineMetaData);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
describe('toString()', () => {
|
|
100
|
-
|
|
101
|
-
test('string output standard', () => {
|
|
102
|
-
const toStringElement = elementTest.toString();
|
|
103
|
-
|
|
104
|
-
expect(toStringElement).toBe(`Component ${KeyTest} - Type: Element`);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
test('string output standard with domain', () => {
|
|
108
|
-
elementTest = new DTElementTest(IDTest, KeyTest, undefined, DomainTest);
|
|
109
|
-
|
|
110
|
-
const toStringElement = elementTest.toString();
|
|
111
|
-
|
|
112
|
-
expect(toStringElement).toBe(`Component ${DomainTest} ${KeyTest} - Type: Element`);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
test('string output standard with owner', () => {
|
|
116
|
-
elementTest.setOwner(OwnerTest);
|
|
117
|
-
|
|
118
|
-
const toStringElement = elementTest.toString();
|
|
119
|
-
|
|
120
|
-
expect(toStringElement).toBe(`Component ${KeyTest} - Type: Element - Owner: ${OwnerTest}`);
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {DTError} from '../../src';
|
|
2
|
-
import {expect} from "@jest/globals";
|
|
3
|
-
import DTComponent from "../../src/core/DTComponent";
|
|
4
|
-
import MockedFunction = jest.MockedFunction;
|
|
5
|
-
import {DTComponentStub} from "./DTComponent.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 CodeTest = 'DTError-code-123456';
|
|
11
|
-
export const MessageTest = 'DTError-message-test';
|
|
12
|
-
export const TimestampTest = 1500000000000;
|
|
13
|
-
|
|
14
|
-
/******************** HELPER TEST CLASS
|
|
15
|
-
* Helper test class, inherits the main component
|
|
16
|
-
* Providing methods to property access and other facilities, in order to avoid using class methods
|
|
17
|
-
* *****/
|
|
18
|
-
export class DTErrorTest extends DTError {
|
|
19
|
-
constructor(
|
|
20
|
-
code: string,
|
|
21
|
-
message: string,
|
|
22
|
-
initiator?: DTComponentStub,
|
|
23
|
-
convicted?: DTComponentStub,
|
|
24
|
-
timestamp?: Date,
|
|
25
|
-
) {
|
|
26
|
-
super(code, message, initiator, convicted);
|
|
27
|
-
if (timestamp) {
|
|
28
|
-
this.timestamp = timestamp;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
_getConvictedId(): string | undefined {
|
|
33
|
-
return (this.convicted as DTComponentStub)._getStubId();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
_getInitiatorId(): string | undefined {
|
|
37
|
-
return (this.initiator as DTComponentStub)._getStubId();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/******************** STUB CLASS
|
|
42
|
-
* Stub class, for using in other component
|
|
43
|
-
* *****/
|
|
44
|
-
export class DTErrorStub extends DTError {
|
|
45
|
-
constructor() {
|
|
46
|
-
super('', '');
|
|
47
|
-
this.code = CodeTest;
|
|
48
|
-
this.message = MessageTest;
|
|
49
|
-
this.timestamp = new Date(Math.random() * 100000000);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/******************** HELPER METHODS
|
|
54
|
-
* Additional helper methods to use with testing
|
|
55
|
-
* *****/
|
|
56
|
-
|
|
57
|
-
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import {afterEach, beforeEach, describe, expect, jest, test,} from '@jest/globals';
|
|
2
|
-
import {CodeTest, DTErrorTest, MessageTest, TimestampTest,} from './DTError.double';
|
|
3
|
-
import {DTComponentStub, IDTest as ComponentIdTest} from './DTComponent.double';
|
|
4
|
-
import {DTError} from "../../src";
|
|
5
|
-
|
|
6
|
-
/************************* TESTS SUITES *******************************/
|
|
7
|
-
describe('class DTError', () => {
|
|
8
|
-
let errorTest: DTErrorTest;
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
const initiatorStub = new DTComponentStub('initiator');
|
|
12
|
-
const convictedStub = new DTComponentStub('convicted');
|
|
13
|
-
errorTest = new DTErrorTest(CodeTest, MessageTest, initiatorStub, convictedStub, new Date(TimestampTest));
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
afterEach(() => {
|
|
17
|
-
jest.resetAllMocks();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe('constructor()', () => {
|
|
21
|
-
test('creation with standard field (code, message and timestamp)', () => {
|
|
22
|
-
const newError = new DTError(CodeTest, MessageTest);
|
|
23
|
-
const currentDate = new Date();
|
|
24
|
-
|
|
25
|
-
expect(newError.getCode()).toBe(CodeTest);
|
|
26
|
-
expect(newError.getMessage()).toBe(MessageTest);
|
|
27
|
-
expect(newError.getTimestamp().toDateString()).toBe(currentDate.toDateString());
|
|
28
|
-
expect(newError.getTimestamp().toTimeString()).toBe(currentDate.toTimeString());
|
|
29
|
-
expect(newError.getInitiator()).toBeUndefined();
|
|
30
|
-
expect(newError.getConvicted()).toBeUndefined();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('creation with initiator component', () => {
|
|
34
|
-
const initiatorStub = new DTComponentStub('initiator');
|
|
35
|
-
const newError = new DTErrorTest(CodeTest, MessageTest, initiatorStub);
|
|
36
|
-
|
|
37
|
-
expect(newError._getInitiatorId()).toBe(`${ComponentIdTest}-initiator`);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test('creation with initiator and convicted component', () => {
|
|
41
|
-
const initiatorStub = new DTComponentStub('initiator');
|
|
42
|
-
const convictedStub = new DTComponentStub('convicted');
|
|
43
|
-
const newError = new DTErrorTest(CodeTest, MessageTest, initiatorStub, convictedStub);
|
|
44
|
-
|
|
45
|
-
expect(newError._getConvictedId()).toBe(`${ComponentIdTest}-convicted`);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('getCode()', () => {
|
|
50
|
-
test('return code property', () => {
|
|
51
|
-
expect(errorTest.getCode()).toBe(CodeTest);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
describe('getMessage()', () => {
|
|
56
|
-
test('return message property', () => {
|
|
57
|
-
expect(errorTest.getMessage()).toBe(MessageTest);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
describe('getTimestamp()', () => {
|
|
62
|
-
test('return timestamp property', () => {
|
|
63
|
-
expect(errorTest.getTimestamp().getTime()).toBe(TimestampTest);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
describe('getInitiator()', () => {
|
|
68
|
-
test('return initiator component when set', () => {
|
|
69
|
-
expect(errorTest._getInitiatorId()).toBe(`${ComponentIdTest}-initiator`);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
describe('getConvicted()', () => {
|
|
74
|
-
test('return convicted component when set', () => {
|
|
75
|
-
expect(errorTest._getConvictedId()).toBe(`${ComponentIdTest}-convicted`);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
});
|