dyo-tools 0.1.0-rc2 → 0.2.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 -0
- package/.eslintignore +2 -0
- package/.eslintrc.json +47 -0
- package/LICENSE +21 -0
- package/Makefile +34 -0
- package/README.md +0 -7
- package/babel.config.js +1 -0
- package/cucumber-report.html +48 -0
- package/cucumber.js +9 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.js +63 -0
- package/dist/constants.js.map +1 -0
- package/dist/core/DTBunch.d.ts +11 -15
- package/dist/core/DTBunch.js +27 -106
- package/dist/core/DTBunch.js.map +1 -1
- package/dist/core/DTComponent.d.ts +13 -5
- package/dist/core/DTComponent.js +39 -1
- package/dist/core/DTComponent.js.map +1 -1
- package/dist/core/DTComponentPhysical.d.ts +10 -0
- package/dist/core/DTComponentPhysical.js +16 -0
- package/dist/core/DTComponentPhysical.js.map +1 -0
- package/dist/core/DTComponentWithMeta.d.ts +2 -2
- package/dist/core/DTComponentWithMeta.js.map +1 -1
- package/dist/core/DTElement.d.ts +2 -7
- package/dist/core/DTElement.js +3 -12
- package/dist/core/DTElement.js.map +1 -1
- package/dist/core/DTManager.d.ts +31 -0
- package/dist/core/DTManager.js +180 -0
- package/dist/core/DTManager.js.map +1 -0
- package/dist/core/DTPlayer.js +1 -1
- package/dist/core/DTPlayer.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/libs/DYOFinder.d.ts +10 -0
- package/dist/libs/DYOFinder.js +96 -0
- package/dist/libs/DYOFinder.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1321
- package/dist/types/index.d.ts +64 -24
- package/dist/types/index.js.map +1 -1
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +29 -0
- package/docs/assets/main.js +58 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1367 -0
- package/docs/index.html +46 -0
- package/e2e/0.2.0/epic1.feature +29 -0
- package/e2e/0.2.0/epic2.feature +22 -0
- package/e2e/0.2.0/epic3.feature +25 -0
- package/e2e/0.2.0/resources/dominion.js +195 -0
- package/e2e/0.2.0/resources/utils.js +27 -0
- package/e2e/0.2.0/support/steps.js +108 -0
- package/e2e/future/epic4.feature +39 -0
- package/e2e/future/resources/dominion.js +238 -0
- package/e2e/future/resources/utils.js +27 -0
- package/jest.config.js +6 -0
- package/package.json +33 -23
- package/src/constants.ts +85 -0
- package/src/core/DTBunch.ts +461 -0
- package/src/core/DTComponent.ts +225 -0
- package/src/core/DTComponentPhysical.ts +39 -0
- package/src/core/DTComponentWithMeta.ts +65 -0
- package/src/core/DTElement.ts +69 -0
- package/src/core/DTError.ts +78 -0
- package/src/core/DTManager.ts +446 -0
- package/src/core/DTPlayer.ts +57 -0
- package/src/index.ts +9 -0
- package/src/libs/DYOFinder.ts +175 -0
- package/src/types/index.ts +162 -0
- package/test/core/DTBunch.double.ts +253 -0
- package/test/core/DTBunch.spec.ts +895 -0
- package/test/core/DTComponent.double.ts +164 -0
- package/test/core/DTComponent.spec.ts +295 -0
- package/test/core/DTComponentPhysical.double.ts +76 -0
- package/test/core/DTComponentPhysical.spec.ts +64 -0
- package/test/core/DTComponentWithMeta.double.ts +115 -0
- package/test/core/DTComponentWithMeta.spec.ts +124 -0
- package/test/core/DTElement.double.ts +147 -0
- package/test/core/DTElement.spec.ts +102 -0
- package/test/core/DTError.double.ts +92 -0
- package/test/core/DTError.spec.ts +89 -0
- package/test/core/DTManager.double.ts +192 -0
- package/test/core/DTManager.spec.ts +902 -0
- package/test/core/DTPlayer.double.ts +64 -0
- package/test/core/DTPlayer.spec.ts +80 -0
- package/test/core/copy.spec.ts +227 -0
- package/test/libs/DYOFinder.double.ts +152 -0
- package/test/libs/DYOFinder.spec.ts +194 -0
- package/tsconfig.dev.json +22 -0
- package/tsconfig.json +21 -0
- package/dist/utils/filters.d.ts +0 -6
- package/dist/utils/filters.js +0 -39
- package/dist/utils/filters.js.map +0 -1
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { expect } from '@jest/globals';
|
|
2
|
+
import { DTManager, DTElement } from '../../src';
|
|
3
|
+
import {
|
|
4
|
+
bunch1IdTest,
|
|
5
|
+
bunch1toObjectTest,
|
|
6
|
+
bunch2IdTest,
|
|
7
|
+
bunch2toObjectTest,
|
|
8
|
+
bunch3IdTest,
|
|
9
|
+
bunch3toObjectTest,
|
|
10
|
+
defaultOptions,
|
|
11
|
+
DTBunchStubLibrary,
|
|
12
|
+
DTBunchTest,
|
|
13
|
+
generateMockedElements,
|
|
14
|
+
} from './DTBunch.double';
|
|
15
|
+
import { DTAcceptedMetaData, DTManagerItemsType, DTManagerOptions } from '../../src/types';
|
|
16
|
+
import DYOFinder from '../../src/libs/DYOFinder';
|
|
17
|
+
|
|
18
|
+
/** ****************** STUB PROPERTIES CONSTANTS
|
|
19
|
+
* Fixed properties to use with double classes, avoid auto generated and easy checking on test
|
|
20
|
+
* **** */
|
|
21
|
+
export const IDTest = 'DTManager-id-1234567';
|
|
22
|
+
export const KeyTest = 'DTManager-key-1234567';
|
|
23
|
+
export const DomainTest = 'DTManager-domain-test';
|
|
24
|
+
export const ScopesTest = ['DTManager-scope-test1', 'DTManager-scope-test2'];
|
|
25
|
+
|
|
26
|
+
/** ****************** HELPER TEST CLASS
|
|
27
|
+
* Helper test class, inherits the main component
|
|
28
|
+
* Providing methods to property access and other facilities, in order to avoid using class methods
|
|
29
|
+
* **** */
|
|
30
|
+
export class DTManagerTest extends DTManager<DTElement<DTAcceptedMetaData>> {
|
|
31
|
+
th_get_id(): string {
|
|
32
|
+
return this._id;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
th_set_id(id: string): void {
|
|
36
|
+
this._id = id;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
th_get_key(): string {
|
|
40
|
+
return this._key;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
th_set_key(key: string): void {
|
|
44
|
+
this._key = key;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
th_get_componentType(): string {
|
|
48
|
+
return this._componentType;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
th_get_items(): any {
|
|
52
|
+
return this._items;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
th_set_items(items: DTManagerItemsType<DTElement<DTAcceptedMetaData>>): void {
|
|
56
|
+
this._items = items;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
th_get_single_item(id: string): any {
|
|
60
|
+
return this._items[id];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
th_get_scopes(): any {
|
|
64
|
+
return this._scopes;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
th_set_scopes(scopes: any): void {
|
|
68
|
+
this._scopes = scopes;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
th_get_library(): any {
|
|
72
|
+
return this._library;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
th_set_library(library: any): void {
|
|
76
|
+
this._library = library;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
th_set_options(options: any): void {
|
|
80
|
+
this._options = {
|
|
81
|
+
...this._options,
|
|
82
|
+
...options,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
th_get_finder(): DYOFinder {
|
|
87
|
+
return this._finder;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
th_get_options(): DTManagerOptions {
|
|
91
|
+
return this._options;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** ****************** STUB CLASS
|
|
96
|
+
* Stub class, for using in other component
|
|
97
|
+
* **** */
|
|
98
|
+
export class DTManagerStub extends DTManagerTest {
|
|
99
|
+
constructor() {
|
|
100
|
+
super();
|
|
101
|
+
this._id = IDTest;
|
|
102
|
+
this._key = KeyTest;
|
|
103
|
+
this._errors = [];
|
|
104
|
+
this._library = new DTBunchStubLibrary();
|
|
105
|
+
this._scopes = [
|
|
106
|
+
'default',
|
|
107
|
+
'virtual',
|
|
108
|
+
...ScopesTest,
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
getId(): string {
|
|
113
|
+
return IDTest;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
getKey(): string {
|
|
117
|
+
return KeyTest;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export class DTManagerStubDomain extends DTManagerTest {
|
|
122
|
+
protected _domain = DomainTest;
|
|
123
|
+
|
|
124
|
+
getDomain(): string {
|
|
125
|
+
return DomainTest;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** ****************** HELPER METHODS
|
|
130
|
+
* Additional helper methods to use with testing
|
|
131
|
+
* **** */
|
|
132
|
+
// Add mocked bunches and elements to a Manager
|
|
133
|
+
export function populateManager(manager: DTManagerTest): DTManagerTest {
|
|
134
|
+
const mockedElements = generateMockedElements(5);
|
|
135
|
+
|
|
136
|
+
// Library
|
|
137
|
+
manager.th_set_library(new DTBunchStubLibrary(mockedElements));
|
|
138
|
+
|
|
139
|
+
// Scopes
|
|
140
|
+
manager.th_set_scopes(ScopesTest);
|
|
141
|
+
|
|
142
|
+
// Bunches
|
|
143
|
+
const bunch1 = new DTBunchTest();
|
|
144
|
+
bunch1.th_set_items(mockedElements);
|
|
145
|
+
bunch1.th_set_id(bunch1IdTest);
|
|
146
|
+
jest.spyOn(bunch1, 'getId').mockImplementation(() => bunch1IdTest);
|
|
147
|
+
jest.spyOn(bunch1, 'getOptions').mockImplementation(() => ({ ...defaultOptions }));
|
|
148
|
+
jest.spyOn(bunch1, 'getAll').mockImplementation(function () { return this._items; });
|
|
149
|
+
jest.spyOn(bunch1, 'toObject').mockImplementation(() => bunch1toObjectTest);
|
|
150
|
+
|
|
151
|
+
const bunch2 = new DTBunchTest();
|
|
152
|
+
bunch2.th_set_items([]);
|
|
153
|
+
bunch2.th_set_id(bunch2IdTest);
|
|
154
|
+
jest.spyOn(bunch2, 'getId').mockImplementation(() => bunch2IdTest);
|
|
155
|
+
jest.spyOn(bunch2, 'getOptions').mockImplementation(() => ({ ...defaultOptions }));
|
|
156
|
+
jest.spyOn(bunch2, 'getAll').mockImplementation(function () { return this._items; });
|
|
157
|
+
jest.spyOn(bunch2, 'toObject').mockImplementation(() => bunch2toObjectTest);
|
|
158
|
+
|
|
159
|
+
const bunch3 = new DTBunchTest();
|
|
160
|
+
bunch3.th_set_items([]);
|
|
161
|
+
bunch3.th_set_id(bunch3IdTest);
|
|
162
|
+
bunch3.th_set_options({ virtualContext: true });
|
|
163
|
+
jest.spyOn(bunch3, 'getId').mockImplementation(() => bunch3IdTest);
|
|
164
|
+
jest.spyOn(bunch3, 'getOptions').mockImplementation(() => ({ ...defaultOptions, virtualContext: true }));
|
|
165
|
+
jest.spyOn(bunch3, 'getAll').mockImplementation(function () { return this._items; });
|
|
166
|
+
jest.spyOn(bunch3, 'toObject').mockImplementation(() => bunch3toObjectTest);
|
|
167
|
+
|
|
168
|
+
const items: DTManagerItemsType<DTElement<DTAcceptedMetaData>> = {
|
|
169
|
+
[bunch1.th_get_id()]: {
|
|
170
|
+
scope: 'default',
|
|
171
|
+
item: bunch1,
|
|
172
|
+
},
|
|
173
|
+
[bunch2.th_get_id()]: {
|
|
174
|
+
scope: ScopesTest[0],
|
|
175
|
+
item: bunch2,
|
|
176
|
+
},
|
|
177
|
+
[bunch3.th_get_id()]: {
|
|
178
|
+
scope: 'virtual',
|
|
179
|
+
item: bunch3,
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
manager.th_set_items(items);
|
|
183
|
+
|
|
184
|
+
return manager;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export const checkManagerItem = (managerTest: DTManagerTest, bunchId: string, scope: string): void => {
|
|
188
|
+
expect(managerTest.th_get_single_item(bunchId)).toBeDefined();
|
|
189
|
+
expect(Object.keys(managerTest.th_get_single_item(bunchId))).toStrictEqual(['scope', 'item']);
|
|
190
|
+
expect(managerTest.th_get_single_item(bunchId).scope).toBe(scope);
|
|
191
|
+
expect(managerTest.th_get_single_item(bunchId).item.th_get_id()).toBe(bunchId);
|
|
192
|
+
};
|