dyo-tools 0.3.2 → 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/constants.d.ts → constants.d.ts} +1 -0
- package/constants.d.ts.map +1 -0
- package/constants.js +67 -0
- package/constants.js.map +1 -0
- package/core/DTAction.d.ts +12 -0
- package/core/DTAction.d.ts.map +1 -0
- package/{dist/core → core}/DTAction.js +3 -6
- package/core/DTAction.js.map +1 -0
- package/{dist/core → core}/DTBunch.d.ts +8 -5
- package/core/DTBunch.d.ts.map +1 -0
- package/{dist/core → core}/DTBunch.js +53 -19
- package/core/DTBunch.js.map +1 -0
- package/core/DTComponent.d.ts +31 -0
- package/core/DTComponent.d.ts.map +1 -0
- package/{dist/core → core}/DTComponent.js +23 -10
- package/core/DTComponent.js.map +1 -0
- package/core/DTComponentPhysical.d.ts +16 -0
- package/core/DTComponentPhysical.d.ts.map +1 -0
- package/core/DTComponentPhysical.js +37 -0
- package/core/DTComponentPhysical.js.map +1 -0
- package/core/DTComponentWithMeta.d.ts +12 -0
- package/core/DTComponentWithMeta.d.ts.map +1 -0
- package/core/DTComponentWithMeta.js +46 -0
- package/core/DTComponentWithMeta.js.map +1 -0
- package/core/DTElement.d.ts +15 -0
- package/core/DTElement.d.ts.map +1 -0
- package/{dist/core → core}/DTElement.js +8 -9
- package/core/DTElement.js.map +1 -0
- package/core/DTError.d.ts +14 -0
- package/core/DTError.d.ts.map +1 -0
- package/{dist/core → core}/DTError.js +1 -5
- package/core/DTError.js.map +1 -0
- package/core/DTManager.d.ts +36 -0
- package/core/DTManager.d.ts.map +1 -0
- package/{dist/core → core}/DTManager.js +84 -26
- package/core/DTManager.js.map +1 -0
- package/core/DTMaster.d.ts +27 -0
- package/core/DTMaster.d.ts.map +1 -0
- package/{dist/core → core}/DTMaster.js +48 -31
- package/core/DTMaster.js.map +1 -0
- package/core/DTModule.d.ts +17 -0
- package/core/DTModule.d.ts.map +1 -0
- package/{dist/core → core}/DTModule.js +6 -6
- package/core/DTModule.js.map +1 -0
- package/{src/index.ts → index.d.ts} +14 -17
- package/index.d.ts.map +1 -0
- package/{dist/index.d.ts → index.js} +1 -0
- package/index.js.map +1 -0
- package/{dist/libs → libs}/DYOFinder.d.ts +1 -0
- package/libs/DYOFinder.d.ts.map +1 -0
- package/{dist/libs → libs}/DYOFinder.js +10 -14
- package/libs/DYOFinder.js.map +1 -0
- package/libs/dix/DIXModule.module.d.ts +8 -0
- package/libs/dix/DIXModule.module.d.ts.map +1 -0
- package/libs/dix/DIXModule.module.js +73 -0
- package/libs/player/DTPlayer.element.d.ts +6 -0
- package/libs/player/DTPlayer.element.d.ts.map +1 -0
- package/libs/player/DTPlayer.element.js +7 -0
- package/libs/player/DTPlayer.element.js.map +1 -0
- package/libs/player/DTPlayer.manager.d.ts +12 -0
- package/libs/player/DTPlayer.manager.d.ts.map +1 -0
- package/libs/player/DTPlayer.manager.js +35 -0
- package/libs/player/DTPlayer.manager.js.map +1 -0
- package/package.json +9 -47
- package/tsconfig.dev.tsbuildinfo +1 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/{dist/types → types}/core.d.ts +40 -12
- package/types/core.d.ts.map +1 -0
- package/{dist/types → types}/core.js +2 -6
- package/types/core.js.map +1 -0
- package/{src/types/index.ts → types/index.d.ts} +3 -2
- package/types/index.d.ts.map +1 -0
- package/types/index.js.map +1 -0
- package/{dist/types → types}/player.d.ts +1 -1
- package/types/player.d.ts.map +1 -0
- package/types/player.js +1 -0
- 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/cucumber-report.html +0 -48
- package/dist/constants.js +0 -63
- package/dist/constants.js.map +0 -1
- package/dist/core/DTAction.d.ts +0 -10
- package/dist/core/DTAction.js.map +0 -1
- package/dist/core/DTBunch.js.map +0 -1
- package/dist/core/DTComponent.d.ts +0 -28
- package/dist/core/DTComponent.js.map +0 -1
- package/dist/core/DTComponentPhysical.d.ts +0 -13
- package/dist/core/DTComponentPhysical.js +0 -22
- package/dist/core/DTComponentPhysical.js.map +0 -1
- package/dist/core/DTComponentWithMeta.d.ts +0 -9
- package/dist/core/DTComponentWithMeta.js +0 -32
- package/dist/core/DTComponentWithMeta.js.map +0 -1
- package/dist/core/DTElement.d.ts +0 -13
- package/dist/core/DTElement.js.map +0 -1
- package/dist/core/DTError.d.ts +0 -13
- package/dist/core/DTError.js.map +0 -1
- package/dist/core/DTManager.d.ts +0 -33
- package/dist/core/DTManager.js.map +0 -1
- package/dist/core/DTMaster.d.ts +0 -24
- package/dist/core/DTMaster.js.map +0 -1
- package/dist/core/DTModule.d.ts +0 -14
- package/dist/core/DTModule.js.map +0 -1
- package/dist/index.js +0 -28
- package/dist/index.js.map +0 -1
- package/dist/libs/DYOFinder.js.map +0 -1
- package/dist/libs/player/DTPlayer.element.d.ts +0 -5
- package/dist/libs/player/DTPlayer.element.js +0 -11
- package/dist/libs/player/DTPlayer.element.js.map +0 -1
- package/dist/libs/player/DTPlayer.manager.d.ts +0 -11
- package/dist/libs/player/DTPlayer.manager.js +0 -42
- package/dist/libs/player/DTPlayer.manager.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/core.js.map +0 -1
- package/dist/types/index.js +0 -19
- package/dist/types/index.js.map +0 -1
- package/dist/types/player.js +0 -3
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -29
- package/docs/assets/main.js +0 -59
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1414
- 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/index.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
- package/src/constants.ts +0 -85
- package/src/core/DTAction.ts +0 -52
- package/src/core/DTBunch.ts +0 -467
- package/src/core/DTComponent.ts +0 -225
- package/src/core/DTComponentPhysical.ts +0 -54
- package/src/core/DTComponentWithMeta.ts +0 -65
- package/src/core/DTElement.ts +0 -102
- package/src/core/DTError.ts +0 -78
- package/src/core/DTManager.ts +0 -465
- package/src/core/DTMaster.ts +0 -318
- package/src/core/DTModule.ts +0 -90
- package/src/libs/DYOFinder.ts +0 -175
- package/src/libs/player/DTPlayer.element.ts +0 -9
- package/src/libs/player/DTPlayer.manager.ts +0 -84
- package/src/types/core.ts +0 -169
- package/src/types/player.ts +0 -6
- package/test/core/DTAction.double.ts +0 -78
- package/test/core/DTAction.spec.ts +0 -76
- package/test/core/DTBunch.double.ts +0 -261
- package/test/core/DTBunch.spec.ts +0 -910
- package/test/core/DTComponent.double.ts +0 -164
- package/test/core/DTComponent.spec.ts +0 -295
- package/test/core/DTComponentPhysical.double.ts +0 -76
- package/test/core/DTComponentPhysical.spec.ts +0 -78
- package/test/core/DTComponentWithMeta.double.ts +0 -115
- package/test/core/DTComponentWithMeta.spec.ts +0 -124
- package/test/core/DTElement.double.ts +0 -163
- package/test/core/DTElement.spec.ts +0 -146
- package/test/core/DTError.double.ts +0 -92
- package/test/core/DTError.spec.ts +0 -89
- package/test/core/DTManager.double.ts +0 -216
- package/test/core/DTManager.spec.ts +0 -965
- package/test/core/DTMaster.double.ts +0 -141
- package/test/core/DTMaster.spec.ts +0 -584
- package/test/core/DTModule.double.ts +0 -80
- package/test/core/DTModule.spec.ts +0 -138
- package/test/core/copy.spec.ts +0 -243
- 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 -22
- package/tsconfig.json +0 -21
- /package/{dist/types/index.d.ts → types/index.js} +0 -0
- /package/{dist/types → types}/player.js.map +0 -0
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import {DTComponent} from "../../src";
|
|
2
|
-
import {DTErrorStub} from "./DTError.double";
|
|
3
|
-
import {jest} from "@jest/globals";
|
|
4
|
-
import {DTComponentOptions} from "../../src/types";
|
|
5
|
-
|
|
6
|
-
interface IOptionsTest extends DTComponentOptions {
|
|
7
|
-
option1: boolean
|
|
8
|
-
option2: boolean
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/******************** STUB PROPERTIES CONSTANTS
|
|
12
|
-
* Fixed properties to use with double classes, avoid auto generated and easy checking on test
|
|
13
|
-
* *****/
|
|
14
|
-
export const IDTest = "DTComponent-id-1234567";
|
|
15
|
-
export const KeyTest = "DTComponent-key-1234567";
|
|
16
|
-
export const ComponentTypeTest = "DTComponent-componentType-test";
|
|
17
|
-
export const ToObjectTest = { type: "DTComponent-test-toObject" };
|
|
18
|
-
export const ToStringTest = "DTComponent-test-toString";
|
|
19
|
-
export const DomainTest = "DTComponent-domain-test";
|
|
20
|
-
export const SubKindTest = "DTComponent-subkind-test";
|
|
21
|
-
|
|
22
|
-
/******************** STUB ABSTRACT IMPLEMENTATION
|
|
23
|
-
* Implementation of abstract component class for tests
|
|
24
|
-
* *****/
|
|
25
|
-
export class DTComponentImpl extends DTComponent<IOptionsTest> {
|
|
26
|
-
protected _componentType: string = ComponentTypeTest;
|
|
27
|
-
|
|
28
|
-
copy(): DTComponent {
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
toObject(): any {
|
|
33
|
-
return ToObjectTest;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
toString(): string {
|
|
37
|
-
return ToStringTest;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/******************** HELPER TEST CLASS
|
|
42
|
-
* Helper test class, inherits the main component
|
|
43
|
-
* Providing methods to property access and other facilities, in order to avoid using class methods
|
|
44
|
-
* *****/
|
|
45
|
-
export class DTComponentTest extends DTComponentImpl {
|
|
46
|
-
th_get_id(): string {
|
|
47
|
-
return this._id;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
th_set_id(id: string): void {
|
|
51
|
-
this._id = id;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
th_get_key(): string {
|
|
55
|
-
return this._key;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
th_set_key(key: string): void {
|
|
59
|
-
this._key = key;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
th_set_componentType(componentType: string): void {
|
|
63
|
-
this._componentType = componentType;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
th_set_domain(domain: string): void {
|
|
67
|
-
this._domain = domain;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
th_set_subKind(subKind: string): void {
|
|
71
|
-
this._subKind = subKind;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
th_get_context(): DTComponent | undefined {
|
|
75
|
-
return this._context;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
th_set_context(context: DTComponentTest): void {
|
|
79
|
-
this._context = context;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
th_get_errors(): Array<DTErrorStub> {
|
|
83
|
-
return this._errors;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
th_set_errors(errors: Array<DTErrorStub>): void {
|
|
87
|
-
this._errors = errors;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
th_get_options(): any {
|
|
91
|
-
return this._options;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
th_set_options(options: any): void {
|
|
95
|
-
this._options = options;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/******************** STUB CLASS
|
|
100
|
-
* Stub class, for using in other component
|
|
101
|
-
* *****/
|
|
102
|
-
export class DTComponentStub extends DTComponentTest {
|
|
103
|
-
private readonly stubId: string;
|
|
104
|
-
|
|
105
|
-
constructor(idSuffix: string = "") {
|
|
106
|
-
super();
|
|
107
|
-
this.stubId = IDTest + (idSuffix && `-${idSuffix}`);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
getId() {
|
|
111
|
-
return this.stubId;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/******************** HELPER METHODS
|
|
116
|
-
* Additional helper methods to use with testing
|
|
117
|
-
* *****/
|
|
118
|
-
// Mocked implementations for overridden methods (for children tests)
|
|
119
|
-
export function mockOverriddenMethods(mock: any) {
|
|
120
|
-
// Constructor
|
|
121
|
-
mock.prototype.constructor.mockImplementation(function (key?: string) {
|
|
122
|
-
this._id = IDTest;
|
|
123
|
-
this._key = key || this._id;
|
|
124
|
-
this._errors = [];
|
|
125
|
-
return this;
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Hierarchy Simulation
|
|
130
|
-
type simulateHierarchyOptions = {
|
|
131
|
-
mockGetContext: boolean
|
|
132
|
-
}
|
|
133
|
-
export function simulateHierarchy(
|
|
134
|
-
ranks: number = 3,
|
|
135
|
-
options: simulateHierarchyOptions = { mockGetContext: false }): DTComponentTest[] {
|
|
136
|
-
const hierarchyComponents = [];
|
|
137
|
-
let lastRankComponent: DTComponentTest;
|
|
138
|
-
|
|
139
|
-
for (let i = 1; i <= ranks; i++) {
|
|
140
|
-
const componentRank = new DTComponentTest();
|
|
141
|
-
componentRank.th_set_componentType(`rank${i}`);
|
|
142
|
-
if (lastRankComponent) {
|
|
143
|
-
componentRank.th_set_context(lastRankComponent);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (options.mockGetContext) {
|
|
147
|
-
if (lastRankComponent) {
|
|
148
|
-
const lastComponentRankScoped = lastRankComponent;
|
|
149
|
-
jest.spyOn(componentRank, 'getContext').mockImplementation(function () {
|
|
150
|
-
return lastComponentRankScoped;
|
|
151
|
-
});
|
|
152
|
-
} else {
|
|
153
|
-
jest.spyOn(componentRank, 'getContext').mockImplementation(function () {
|
|
154
|
-
return undefined;
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
hierarchyComponents.push(componentRank);
|
|
160
|
-
lastRankComponent = componentRank;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return hierarchyComponents;
|
|
164
|
-
}
|
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
import {afterEach, beforeEach, describe, expect, jest, test,} from '@jest/globals';
|
|
2
|
-
import {
|
|
3
|
-
ComponentTypeTest,
|
|
4
|
-
DomainTest,
|
|
5
|
-
DTComponentTest,
|
|
6
|
-
DTComponentImpl,
|
|
7
|
-
IDTest,
|
|
8
|
-
KeyTest,
|
|
9
|
-
simulateHierarchy,
|
|
10
|
-
SubKindTest,
|
|
11
|
-
} from './DTComponent.double';
|
|
12
|
-
import {DTErrorStub} from "./DTError.double";
|
|
13
|
-
|
|
14
|
-
describe('class DYOToolsComponent', () => {
|
|
15
|
-
let componentTest: DTComponentTest;
|
|
16
|
-
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
componentTest = new DTComponentTest();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
afterEach(() => {
|
|
22
|
-
jest.clearAllMocks();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('constructor()', () => {
|
|
26
|
-
test('creation without key', () => {
|
|
27
|
-
const component = new DTComponentTest();
|
|
28
|
-
const component2 = new DTComponentTest(null);
|
|
29
|
-
|
|
30
|
-
expect(component.th_get_key()).toBe(component.th_get_id());
|
|
31
|
-
expect(component2.th_get_key()).toBe(component2.th_get_id());
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('creation with key', () => {
|
|
35
|
-
const component = new DTComponentTest(KeyTest);
|
|
36
|
-
|
|
37
|
-
expect(component.th_get_key()).toBe(KeyTest);
|
|
38
|
-
expect(component.th_get_id() !== component.th_get_key()).toBeTruthy();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('creations have unique ids', () => {
|
|
42
|
-
const component = new DTComponentTest(KeyTest);
|
|
43
|
-
const component2 = new DTComponentTest(KeyTest);
|
|
44
|
-
|
|
45
|
-
expect(component.th_get_id() !== component2.th_get_id()).toBeTruthy();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('creations without options - default', () => {
|
|
49
|
-
const component = new DTComponentTest();
|
|
50
|
-
|
|
51
|
-
expect(component.th_get_options()).toStrictEqual({
|
|
52
|
-
errors: false
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('creations with options', () => {
|
|
57
|
-
const component = new DTComponentTest(KeyTest, { errors: true, option1: false, option2: true });
|
|
58
|
-
|
|
59
|
-
expect(component.th_get_options()).toStrictEqual({
|
|
60
|
-
errors: true,
|
|
61
|
-
option1: false,
|
|
62
|
-
option2: true
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
describe('getId()', () => {
|
|
68
|
-
test('return id', () => {
|
|
69
|
-
componentTest.th_set_id(IDTest);
|
|
70
|
-
expect(componentTest.getId()).toBe(IDTest);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
describe('getKey()', () => {
|
|
75
|
-
test('return key', () => {
|
|
76
|
-
componentTest.th_set_key(KeyTest);
|
|
77
|
-
expect(componentTest.getKey()).toBe(KeyTest);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
describe('getComponentType()', () => {
|
|
82
|
-
test('return componentType', () => {
|
|
83
|
-
const componentTestSet = new DTComponentTest();
|
|
84
|
-
componentTestSet.th_set_componentType(`${ComponentTypeTest}-set`);
|
|
85
|
-
|
|
86
|
-
expect(componentTest.getComponentType()).toBe(ComponentTypeTest);
|
|
87
|
-
expect(componentTestSet.getComponentType()).toBe(`${ComponentTypeTest}-set`);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
describe('getDomain()', () => {
|
|
92
|
-
test('return domain', () => {
|
|
93
|
-
const componentTestSet = new DTComponentTest();
|
|
94
|
-
componentTestSet.th_set_domain(DomainTest);
|
|
95
|
-
|
|
96
|
-
expect(componentTest.getDomain()).toBeUndefined();
|
|
97
|
-
expect(componentTestSet.getDomain()).toBe(DomainTest);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
describe('getSubKind()', () => {
|
|
102
|
-
test('return subkind', () => {
|
|
103
|
-
const componentTestSet = new DTComponentTest();
|
|
104
|
-
componentTestSet.th_set_subKind(SubKindTest);
|
|
105
|
-
|
|
106
|
-
expect(componentTest.getSubKind()).toBeUndefined();
|
|
107
|
-
expect(componentTestSet.getSubKind()).toBe(SubKindTest);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe('getContext()', () => {
|
|
112
|
-
beforeEach(() => {
|
|
113
|
-
componentTest = new DTComponentTest();
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
test('return context', () => {
|
|
117
|
-
const component = new DTComponentTest();
|
|
118
|
-
const componentTestSet = new DTComponentTest();
|
|
119
|
-
componentTestSet.th_set_context(component);
|
|
120
|
-
jest.spyOn(component, 'getComponentType').mockImplementation(function () {
|
|
121
|
-
return this._componentType;
|
|
122
|
-
});
|
|
123
|
-
jest.spyOn(componentTestSet, 'getComponentType').mockImplementation(function () {
|
|
124
|
-
return this._componentType;
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
expect(componentTest.getContext()).toBeUndefined();
|
|
128
|
-
expect(componentTestSet.getContext()).toStrictEqual(component);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
test('return context with Hierarchy - simple case', () => {
|
|
132
|
-
const [componentRank1, componentRank2, componentRank3] = simulateHierarchy();
|
|
133
|
-
jest.spyOn(componentRank3, 'getComponentType').mockImplementation(function () {
|
|
134
|
-
return this._componentType;
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
expect(componentRank3.getContext()).toStrictEqual(componentRank2);
|
|
138
|
-
expect(componentRank3.getContext('rank2')).toStrictEqual(componentRank2);
|
|
139
|
-
expect(componentRank3.getContext('rank1')).toStrictEqual(componentRank1);
|
|
140
|
-
expect(componentRank3.getContext('rank0')).toBeUndefined();
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
test('return context with Hierarchy - same type case so return first one', () => {
|
|
144
|
-
const [componentRank0, componentRank2, componentRank3] = simulateHierarchy();
|
|
145
|
-
const componentRank1 = new DTComponentTest();
|
|
146
|
-
componentRank1.th_set_componentType('rank1');
|
|
147
|
-
componentRank1.th_set_context(componentRank0);
|
|
148
|
-
componentRank2.th_set_context(componentRank1);
|
|
149
|
-
jest.spyOn(componentRank1, 'getComponentType').mockImplementation(function () {
|
|
150
|
-
return this._componentType;
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
expect(componentRank3.getContext('rank1')).toStrictEqual(componentRank1);
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
describe('setContext()', () => {
|
|
158
|
-
test('change context', () => {
|
|
159
|
-
const componentRank1 = new DTComponentTest();
|
|
160
|
-
componentRank1.th_set_componentType('rank1');
|
|
161
|
-
|
|
162
|
-
componentTest.setContext(componentRank1);
|
|
163
|
-
expect(componentTest.th_get_context()).toBe(componentRank1);
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
describe('removeContext()', () => {
|
|
168
|
-
test('remove the current Context', () => {
|
|
169
|
-
const componentRankSup = new DTComponentTest();
|
|
170
|
-
componentTest.th_set_context(componentRankSup);
|
|
171
|
-
|
|
172
|
-
componentTest.removeContext();
|
|
173
|
-
expect(componentTest.th_get_context()).toBeUndefined();
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
describe('getErrors()', () => {
|
|
178
|
-
test('return empty errors by default', () => {
|
|
179
|
-
expect(componentTest.getErrors()).toStrictEqual([]);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
test('return array of errors if defined', () => {
|
|
183
|
-
const errors = [new DTErrorStub(), new DTErrorStub()];
|
|
184
|
-
componentTest.th_set_errors(errors);
|
|
185
|
-
|
|
186
|
-
expect(componentTest.getErrors()).toStrictEqual(errors);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
test('return errors from higher level component', () => {
|
|
190
|
-
const [componentRank1, componentRank2, componentRank3] = simulateHierarchy(3, { mockGetContext: true });
|
|
191
|
-
componentRank1.th_set_errors([new DTErrorStub(), new DTErrorStub(), new DTErrorStub()]);
|
|
192
|
-
componentRank2.th_set_errors([new DTErrorStub(), new DTErrorStub()]);
|
|
193
|
-
componentRank3.th_set_errors([new DTErrorStub()]);
|
|
194
|
-
|
|
195
|
-
expect(componentRank1.getErrors().length).toEqual(3);
|
|
196
|
-
expect(componentRank2.getErrors().length).toEqual(3);
|
|
197
|
-
expect(componentRank3.getErrors().length).toEqual(3);
|
|
198
|
-
})
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
describe('getLastError()', () => {
|
|
202
|
-
test('return undefined if no errors', () => {
|
|
203
|
-
expect(componentTest.getLastError()).toBeUndefined();
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
test('return the last error', () => {
|
|
207
|
-
const lastError = new DTErrorStub();
|
|
208
|
-
const errors = [new DTErrorStub(), new DTErrorStub(), lastError];
|
|
209
|
-
componentTest.th_set_errors(errors);
|
|
210
|
-
|
|
211
|
-
expect(componentTest.getLastError().getTimestamp().toString()).toStrictEqual(lastError.getTimestamp().toString());
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
test('return the last error from higher level component', () => {
|
|
215
|
-
const [componentRank1, componentRank2, componentRank3] = simulateHierarchy(3, { mockGetContext: true });
|
|
216
|
-
const lastError = new DTErrorStub();
|
|
217
|
-
componentRank1.th_set_errors([new DTErrorStub(), new DTErrorStub(), lastError]);
|
|
218
|
-
componentRank2.th_set_errors([new DTErrorStub(), new DTErrorStub()]);
|
|
219
|
-
componentRank3.th_set_errors([new DTErrorStub()]);
|
|
220
|
-
|
|
221
|
-
expect(componentRank1.getLastError().getTimestamp().toString()).toStrictEqual(lastError.getTimestamp().toString());
|
|
222
|
-
expect(componentRank2.getLastError().getTimestamp().toString()).toStrictEqual(lastError.getTimestamp().toString());
|
|
223
|
-
expect(componentRank3.getLastError().getTimestamp().toString()).toStrictEqual(lastError.getTimestamp().toString());
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
describe('triggerError()', () => {
|
|
228
|
-
test('default throw an exception error - option errors false', () => {
|
|
229
|
-
const error = new DTErrorStub();
|
|
230
|
-
|
|
231
|
-
expect(() => componentTest.triggerError(error)).toThrow(error);
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
test('stack new error - option errors true', () => {
|
|
235
|
-
componentTest.th_set_options({ errors: true });
|
|
236
|
-
const error = new DTErrorStub();
|
|
237
|
-
|
|
238
|
-
componentTest.triggerError(error);
|
|
239
|
-
expect(componentTest.th_get_errors().length).toBe(1);
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
test('throw new error in higher level component - option errors false', () => {
|
|
243
|
-
const [componentRank1, componentRank2, componentRank3] = simulateHierarchy(3, { mockGetContext: true });
|
|
244
|
-
componentRank1.th_set_options({ errors: false });
|
|
245
|
-
componentRank2.th_set_options({ errors: true });
|
|
246
|
-
componentRank3.th_set_options({ errors: true });
|
|
247
|
-
const error = new DTErrorStub();
|
|
248
|
-
|
|
249
|
-
expect(() => componentRank3.triggerError(error)).toThrow(error);
|
|
250
|
-
expect(componentRank2.th_get_errors().length).toBe(0);
|
|
251
|
-
expect(componentRank1.th_get_errors().length).toBe(0);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
test('stack new error in higher level component - option errors true', () => {
|
|
255
|
-
const [componentRank1, componentRank2, componentRank3] = simulateHierarchy(3, { mockGetContext: true });
|
|
256
|
-
componentRank1.th_set_options({ errors: true });
|
|
257
|
-
componentRank2.th_set_options({ errors: false });
|
|
258
|
-
const error = new DTErrorStub();
|
|
259
|
-
|
|
260
|
-
componentRank3.triggerError(error);
|
|
261
|
-
expect(componentRank1.th_get_errors().length).toBe(1);
|
|
262
|
-
expect(componentRank2.th_get_errors().length).toBe(0);
|
|
263
|
-
expect(componentRank3.th_get_errors().length).toBe(0);
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
describe('clearErrors()', () => {
|
|
268
|
-
test('reset errors array', () => {
|
|
269
|
-
componentTest.th_set_errors([new DTErrorStub(), new DTErrorStub()]);
|
|
270
|
-
|
|
271
|
-
componentTest.clearErrors();
|
|
272
|
-
expect(componentTest.th_get_errors().length).toBe(0);
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
test('reset errors in higher level components', () => {
|
|
276
|
-
const [componentRank1, componentRank2, componentRank3] = simulateHierarchy(3, { mockGetContext: true });
|
|
277
|
-
componentRank1.th_set_errors([new DTErrorStub(), new DTErrorStub(), new DTErrorStub()]);
|
|
278
|
-
componentRank2.th_set_errors([new DTErrorStub(), new DTErrorStub()]);
|
|
279
|
-
componentRank3.th_set_errors([new DTErrorStub()]);
|
|
280
|
-
|
|
281
|
-
componentRank3.clearErrors();
|
|
282
|
-
expect(componentRank1.th_get_errors().length).toBe(0);
|
|
283
|
-
expect(componentRank2.th_get_errors().length).toBe(0);
|
|
284
|
-
expect(componentRank3.th_get_errors().length).toBe(0);
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
describe('getOptions()', () => {
|
|
289
|
-
test('return options', () => {
|
|
290
|
-
componentTest.th_set_options({ errors: true, option1: false, option2: true });
|
|
291
|
-
|
|
292
|
-
expect(componentTest.getOptions()).toStrictEqual({ errors: true, option1: false, option2: true });
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import {DTComponentPhysical} from "../../src";
|
|
2
|
-
import {IMetaDataTest} from "./DTComponentWithMeta.double";
|
|
3
|
-
|
|
4
|
-
/******************** STUB PROPERTIES CONSTANTS
|
|
5
|
-
* Fixed properties to use with double classes, avoid auto generated and easy checking on test
|
|
6
|
-
* *****/
|
|
7
|
-
export const IDTest = "DTComponentPhysical-id-1234567";
|
|
8
|
-
export const KeyTest = "DTComponentPhysical-key-1234567";
|
|
9
|
-
export const ComponentTypeTest = "DTComponentPhysical-componentType-test";
|
|
10
|
-
export const ToObjectTest = { type: "DTComponentPhysical-test-toObject" };
|
|
11
|
-
export const ToStringTest = "DTComponentPhysical-test-toString";
|
|
12
|
-
export const OwnerTest = "owner-12345";
|
|
13
|
-
|
|
14
|
-
/******************** STUB ABSTRACT IMPLEMENTATION
|
|
15
|
-
* Implementation of abstract component class for tests
|
|
16
|
-
* *****/
|
|
17
|
-
export class DTComponentPhysicalImpl extends DTComponentPhysical<IMetaDataTest> {
|
|
18
|
-
protected _componentType: string = ComponentTypeTest;
|
|
19
|
-
|
|
20
|
-
copy(): DTComponentPhysical<IMetaDataTest> {
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
toObject(): any {
|
|
25
|
-
return ToObjectTest;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
toString(): string {
|
|
29
|
-
return ToStringTest;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
do(): void {
|
|
33
|
-
}
|
|
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 DTComponentPhysicalTest extends DTComponentPhysicalImpl {
|
|
41
|
-
th_get_owner(): string {
|
|
42
|
-
return this._owner;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
th_set_owner(owner: string): void {
|
|
46
|
-
this._owner = owner;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/******************** STUB CLASS
|
|
51
|
-
* Stub class, for using in other component
|
|
52
|
-
* *****/
|
|
53
|
-
export class DTComponentPhysicalStub extends DTComponentPhysicalTest {
|
|
54
|
-
private readonly stubId: string;
|
|
55
|
-
|
|
56
|
-
constructor(idSuffix: string = "") {
|
|
57
|
-
super();
|
|
58
|
-
this.stubId = IDTest + (idSuffix && `-${idSuffix}`);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
getId() {
|
|
62
|
-
return this.stubId;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/******************** HELPER METHODS
|
|
67
|
-
* Additional helper methods to use with testing
|
|
68
|
-
* *****/
|
|
69
|
-
// Mocked implementations for overridden methods (for children tests)
|
|
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
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
|
2
|
-
import {mockOverriddenMethods} from "./DTComponentWithMeta.double";
|
|
3
|
-
import {DTComponentPhysicalTest, OwnerTest} from './DTComponentPhysical.double';
|
|
4
|
-
import {DTComponentPhysical, DTComponentWithMeta} from "../../src";
|
|
5
|
-
|
|
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
|
-
/************************* TESTS SUITES *******************************/
|
|
15
|
-
describe('class DYOToolsComponentPhysical', () => {
|
|
16
|
-
let componentPhysicalTest: DTComponentPhysicalTest;
|
|
17
|
-
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
componentPhysicalTest = new DTComponentPhysicalTest();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
afterEach(() => {
|
|
23
|
-
jest.resetAllMocks();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe('inheritance', () => {
|
|
27
|
-
test('check good inheritance for class', () => {
|
|
28
|
-
expect(DTComponentPhysical.prototype instanceof DTComponentWithMeta).toBeTruthy();
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe('getManager()', () => {
|
|
33
|
-
test('call get context with manager accessor', () => {
|
|
34
|
-
componentPhysicalTest.getManager();
|
|
35
|
-
|
|
36
|
-
expect((componentPhysicalTest.getContext as any).mock.calls.length).toBe(1);
|
|
37
|
-
expect((componentPhysicalTest.getContext as any).mock.calls[0][0]).toBe('manager');
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe('getMaster()', () => {
|
|
42
|
-
test('call get context with master accessor', () => {
|
|
43
|
-
componentPhysicalTest.getMaster();
|
|
44
|
-
|
|
45
|
-
expect((componentPhysicalTest.getContext as any).mock.calls.length).toBe(1);
|
|
46
|
-
expect((componentPhysicalTest.getContext as any).mock.calls[0][0]).toBe('master');
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
describe('getOwner()', () => {
|
|
51
|
-
test('return empty owner by default', () => {
|
|
52
|
-
expect(componentPhysicalTest.getOwner()).toBeUndefined();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('return owner when set', () => {
|
|
56
|
-
componentPhysicalTest.th_set_owner(OwnerTest);
|
|
57
|
-
|
|
58
|
-
expect(componentPhysicalTest.getOwner()).toBe(OwnerTest);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe('setOwner()', () => {
|
|
63
|
-
test('add a new owner', () => {
|
|
64
|
-
componentPhysicalTest.setOwner(OwnerTest);
|
|
65
|
-
|
|
66
|
-
expect(componentPhysicalTest.th_get_owner()).toBe(OwnerTest);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
describe('removeOwner()', () => {
|
|
71
|
-
test('remove the current Owner', () => {
|
|
72
|
-
componentPhysicalTest.th_set_owner(OwnerTest);
|
|
73
|
-
|
|
74
|
-
componentPhysicalTest.removeOwner();
|
|
75
|
-
expect(componentPhysicalTest.th_get_owner()).toBeUndefined();
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
});
|