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