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.
Files changed (239) hide show
  1. package/{dist/constants.d.ts → constants.d.ts} +1 -0
  2. package/constants.d.ts.map +1 -0
  3. package/constants.js +67 -0
  4. package/constants.js.map +1 -0
  5. package/core/DTAction.d.ts +12 -0
  6. package/core/DTAction.d.ts.map +1 -0
  7. package/{dist/core → core}/DTAction.js +3 -6
  8. package/core/DTAction.js.map +1 -0
  9. package/{dist/core → core}/DTBunch.d.ts +8 -5
  10. package/core/DTBunch.d.ts.map +1 -0
  11. package/{dist/core → core}/DTBunch.js +53 -19
  12. package/core/DTBunch.js.map +1 -0
  13. package/core/DTComponent.d.ts +31 -0
  14. package/core/DTComponent.d.ts.map +1 -0
  15. package/{dist/core → core}/DTComponent.js +23 -10
  16. package/core/DTComponent.js.map +1 -0
  17. package/core/DTComponentPhysical.d.ts +16 -0
  18. package/core/DTComponentPhysical.d.ts.map +1 -0
  19. package/core/DTComponentPhysical.js +37 -0
  20. package/core/DTComponentPhysical.js.map +1 -0
  21. package/core/DTComponentWithMeta.d.ts +12 -0
  22. package/core/DTComponentWithMeta.d.ts.map +1 -0
  23. package/core/DTComponentWithMeta.js +46 -0
  24. package/core/DTComponentWithMeta.js.map +1 -0
  25. package/core/DTElement.d.ts +15 -0
  26. package/core/DTElement.d.ts.map +1 -0
  27. package/{dist/core → core}/DTElement.js +8 -9
  28. package/core/DTElement.js.map +1 -0
  29. package/core/DTError.d.ts +14 -0
  30. package/core/DTError.d.ts.map +1 -0
  31. package/{dist/core → core}/DTError.js +1 -5
  32. package/core/DTError.js.map +1 -0
  33. package/core/DTManager.d.ts +36 -0
  34. package/core/DTManager.d.ts.map +1 -0
  35. package/{dist/core → core}/DTManager.js +84 -26
  36. package/core/DTManager.js.map +1 -0
  37. package/core/DTMaster.d.ts +27 -0
  38. package/core/DTMaster.d.ts.map +1 -0
  39. package/{dist/core → core}/DTMaster.js +48 -31
  40. package/core/DTMaster.js.map +1 -0
  41. package/core/DTModule.d.ts +17 -0
  42. package/core/DTModule.d.ts.map +1 -0
  43. package/{dist/core → core}/DTModule.js +6 -6
  44. package/core/DTModule.js.map +1 -0
  45. package/{src/index.ts → index.d.ts} +14 -17
  46. package/index.d.ts.map +1 -0
  47. package/{dist/index.d.ts → index.js} +1 -0
  48. package/index.js.map +1 -0
  49. package/{dist/libs → libs}/DYOFinder.d.ts +1 -0
  50. package/libs/DYOFinder.d.ts.map +1 -0
  51. package/{dist/libs → libs}/DYOFinder.js +10 -14
  52. package/libs/DYOFinder.js.map +1 -0
  53. package/libs/dix/DIXModule.module.d.ts +8 -0
  54. package/libs/dix/DIXModule.module.d.ts.map +1 -0
  55. package/libs/dix/DIXModule.module.js +73 -0
  56. package/libs/player/DTPlayer.element.d.ts +6 -0
  57. package/libs/player/DTPlayer.element.d.ts.map +1 -0
  58. package/libs/player/DTPlayer.element.js +7 -0
  59. package/libs/player/DTPlayer.element.js.map +1 -0
  60. package/libs/player/DTPlayer.manager.d.ts +12 -0
  61. package/libs/player/DTPlayer.manager.d.ts.map +1 -0
  62. package/libs/player/DTPlayer.manager.js +35 -0
  63. package/libs/player/DTPlayer.manager.js.map +1 -0
  64. package/package.json +9 -47
  65. package/tsconfig.dev.tsbuildinfo +1 -0
  66. package/tsconfig.tsbuildinfo +1 -0
  67. package/{dist/types → types}/core.d.ts +40 -12
  68. package/types/core.d.ts.map +1 -0
  69. package/{dist/types → types}/core.js +2 -6
  70. package/types/core.js.map +1 -0
  71. package/{src/types/index.ts → types/index.d.ts} +3 -2
  72. package/types/index.d.ts.map +1 -0
  73. package/types/index.js.map +1 -0
  74. package/{dist/types → types}/player.d.ts +1 -1
  75. package/types/player.d.ts.map +1 -0
  76. package/types/player.js +1 -0
  77. package/.c8rc.json +0 -4
  78. package/.eslintignore +0 -2
  79. package/.eslintrc.json +0 -47
  80. package/Makefile +0 -34
  81. package/README.md +0 -0
  82. package/babel.config.js +0 -1
  83. package/cucumber-report.html +0 -48
  84. package/dist/constants.js +0 -63
  85. package/dist/constants.js.map +0 -1
  86. package/dist/core/DTAction.d.ts +0 -10
  87. package/dist/core/DTAction.js.map +0 -1
  88. package/dist/core/DTBunch.js.map +0 -1
  89. package/dist/core/DTComponent.d.ts +0 -28
  90. package/dist/core/DTComponent.js.map +0 -1
  91. package/dist/core/DTComponentPhysical.d.ts +0 -13
  92. package/dist/core/DTComponentPhysical.js +0 -22
  93. package/dist/core/DTComponentPhysical.js.map +0 -1
  94. package/dist/core/DTComponentWithMeta.d.ts +0 -9
  95. package/dist/core/DTComponentWithMeta.js +0 -32
  96. package/dist/core/DTComponentWithMeta.js.map +0 -1
  97. package/dist/core/DTElement.d.ts +0 -13
  98. package/dist/core/DTElement.js.map +0 -1
  99. package/dist/core/DTError.d.ts +0 -13
  100. package/dist/core/DTError.js.map +0 -1
  101. package/dist/core/DTManager.d.ts +0 -33
  102. package/dist/core/DTManager.js.map +0 -1
  103. package/dist/core/DTMaster.d.ts +0 -24
  104. package/dist/core/DTMaster.js.map +0 -1
  105. package/dist/core/DTModule.d.ts +0 -14
  106. package/dist/core/DTModule.js.map +0 -1
  107. package/dist/index.js +0 -28
  108. package/dist/index.js.map +0 -1
  109. package/dist/libs/DYOFinder.js.map +0 -1
  110. package/dist/libs/player/DTPlayer.element.d.ts +0 -5
  111. package/dist/libs/player/DTPlayer.element.js +0 -11
  112. package/dist/libs/player/DTPlayer.element.js.map +0 -1
  113. package/dist/libs/player/DTPlayer.manager.d.ts +0 -11
  114. package/dist/libs/player/DTPlayer.manager.js +0 -42
  115. package/dist/libs/player/DTPlayer.manager.js.map +0 -1
  116. package/dist/tsconfig.tsbuildinfo +0 -1
  117. package/dist/types/core.js.map +0 -1
  118. package/dist/types/index.js +0 -19
  119. package/dist/types/index.js.map +0 -1
  120. package/dist/types/player.js +0 -3
  121. package/docs/.nojekyll +0 -1
  122. package/docs/assets/highlight.css +0 -29
  123. package/docs/assets/main.js +0 -59
  124. package/docs/assets/navigation.js +0 -1
  125. package/docs/assets/search.js +0 -1
  126. package/docs/assets/style.css +0 -1414
  127. package/docs/classes/core_DTAction.DYOToolsAction.html +0 -89
  128. package/docs/classes/core_DTBunch.DYOToolsBunch.html +0 -254
  129. package/docs/classes/core_DTComponent.DYOToolsComponent.html +0 -76
  130. package/docs/classes/core_DTComponentPhysical.DYOToolsComponentPhysical.html +0 -110
  131. package/docs/classes/core_DTComponentWithMeta.DYOToolsComponentWithMeta.html +0 -96
  132. package/docs/classes/core_DTElement.DYOToolsElement.html +0 -135
  133. package/docs/classes/core_DTError.DYOToolsError.html +0 -37
  134. package/docs/classes/core_DTManager.DYOToolsManager.html +0 -237
  135. package/docs/classes/core_DTMaster.DYOToolsMaster.html +0 -150
  136. package/docs/classes/core_DTModule.DYOToolsModule.html +0 -92
  137. package/docs/classes/libs_DYOFinder.DYOFinder.html +0 -34
  138. package/docs/classes/libs_player_DTPlayer_element.DYOToolsPlayer.html +0 -134
  139. package/docs/classes/libs_player_DTPlayer_manager.DYOToolsPlayerManager.html +0 -243
  140. package/docs/enums/types_core.FilterOperatorType.html +0 -10
  141. package/docs/hierarchy.html +0 -1
  142. package/docs/index.html +0 -1
  143. package/docs/interfaces/types_core.DTBunchFilters.html +0 -6
  144. package/docs/interfaces/types_core.DTBunchOptions.html +0 -19
  145. package/docs/interfaces/types_core.DTBunchToObject.html +0 -7
  146. package/docs/interfaces/types_core.DTComponentOptions.html +0 -5
  147. package/docs/interfaces/types_core.DTComponentToObject.html +0 -4
  148. package/docs/interfaces/types_core.DTElementToObject.html +0 -7
  149. package/docs/interfaces/types_core.DTManagerFilters.html +0 -6
  150. package/docs/interfaces/types_core.DTManagerOptions.html +0 -8
  151. package/docs/interfaces/types_core.DTManagerToObject.html +0 -5
  152. package/docs/interfaces/types_core.DTMasterToObject.html +0 -8
  153. package/docs/interfaces/types_core.DTModuleToObject.html +0 -6
  154. package/docs/interfaces/types_core.DYOFinderConfigurationPropDefault.html +0 -4
  155. package/docs/interfaces/types_core.DYOFinderConfigurationPropObjectSearch.html +0 -4
  156. package/docs/interfaces/types_core.DYOFinderFilterOperatorAdvanced.html +0 -5
  157. package/docs/interfaces/types_core.DYOFinderFilterOperatorBase.html +0 -5
  158. package/docs/interfaces/types_player.DTPlayerManagerSimpleConfiguration.html +0 -3
  159. package/docs/modules/constants.html +0 -6
  160. package/docs/modules/core_DTAction.html +0 -2
  161. package/docs/modules/core_DTBunch.html +0 -2
  162. package/docs/modules/core_DTComponent.html +0 -2
  163. package/docs/modules/core_DTComponentPhysical.html +0 -2
  164. package/docs/modules/core_DTComponentWithMeta.html +0 -2
  165. package/docs/modules/core_DTElement.html +0 -2
  166. package/docs/modules/core_DTError.html +0 -2
  167. package/docs/modules/core_DTManager.html +0 -2
  168. package/docs/modules/core_DTMaster.html +0 -2
  169. package/docs/modules/core_DTModule.html +0 -2
  170. package/docs/modules/libs_DYOFinder.html +0 -2
  171. package/docs/modules/libs_player_DTPlayer_element.html +0 -2
  172. package/docs/modules/libs_player_DTPlayer_manager.html +0 -2
  173. package/docs/modules/types.html +0 -29
  174. package/docs/modules/types_core.html +0 -28
  175. package/docs/modules/types_player.html +0 -2
  176. package/docs/types/types_core.DTAcceptedMetaData.html +0 -2
  177. package/docs/types/types_core.DTManagerItemType.html +0 -1
  178. package/docs/types/types_core.DTManagerItemsType.html +0 -2
  179. package/docs/types/types_core.DYOFinderComponentType.html +0 -1
  180. package/docs/types/types_core.DYOFinderConfiguration.html +0 -2
  181. package/docs/types/types_core.DYOFinderConfigurationProp.html +0 -1
  182. package/docs/types/types_core.DYOFinderFilterOperator.html +0 -1
  183. package/docs/types/types_core.DYOFinderFilterOperatorArgument.html +0 -1
  184. package/docs/types/types_core.DYOFinderFilters.html +0 -1
  185. package/docs/types/types_core.StandardPrimitiveType.html +0 -2
  186. package/docs/types/types_core.StandardPrimitiveTypeWithArray.html +0 -1
  187. package/docs/variables/constants.bunchDefaultOptions.html +0 -2
  188. package/docs/variables/constants.componentBunchDefaultFinderConfiguration.html +0 -1
  189. package/docs/variables/constants.componentManagerDefaultFinderConfiguration.html +0 -1
  190. package/docs/variables/constants.componentPhysicalDefaultFinderConfiguration.html +0 -1
  191. package/docs/variables/constants.managerDefaultOptions.html +0 -2
  192. package/jest.config.js +0 -6
  193. package/src/constants.ts +0 -85
  194. package/src/core/DTAction.ts +0 -52
  195. package/src/core/DTBunch.ts +0 -467
  196. package/src/core/DTComponent.ts +0 -225
  197. package/src/core/DTComponentPhysical.ts +0 -54
  198. package/src/core/DTComponentWithMeta.ts +0 -65
  199. package/src/core/DTElement.ts +0 -102
  200. package/src/core/DTError.ts +0 -78
  201. package/src/core/DTManager.ts +0 -465
  202. package/src/core/DTMaster.ts +0 -318
  203. package/src/core/DTModule.ts +0 -90
  204. package/src/libs/DYOFinder.ts +0 -175
  205. package/src/libs/player/DTPlayer.element.ts +0 -9
  206. package/src/libs/player/DTPlayer.manager.ts +0 -84
  207. package/src/types/core.ts +0 -169
  208. package/src/types/player.ts +0 -6
  209. package/test/core/DTAction.double.ts +0 -78
  210. package/test/core/DTAction.spec.ts +0 -76
  211. package/test/core/DTBunch.double.ts +0 -261
  212. package/test/core/DTBunch.spec.ts +0 -910
  213. package/test/core/DTComponent.double.ts +0 -164
  214. package/test/core/DTComponent.spec.ts +0 -295
  215. package/test/core/DTComponentPhysical.double.ts +0 -76
  216. package/test/core/DTComponentPhysical.spec.ts +0 -78
  217. package/test/core/DTComponentWithMeta.double.ts +0 -115
  218. package/test/core/DTComponentWithMeta.spec.ts +0 -124
  219. package/test/core/DTElement.double.ts +0 -163
  220. package/test/core/DTElement.spec.ts +0 -146
  221. package/test/core/DTError.double.ts +0 -92
  222. package/test/core/DTError.spec.ts +0 -89
  223. package/test/core/DTManager.double.ts +0 -216
  224. package/test/core/DTManager.spec.ts +0 -965
  225. package/test/core/DTMaster.double.ts +0 -141
  226. package/test/core/DTMaster.spec.ts +0 -584
  227. package/test/core/DTModule.double.ts +0 -80
  228. package/test/core/DTModule.spec.ts +0 -138
  229. package/test/core/copy.spec.ts +0 -243
  230. package/test/libs/DYOFinder.double.ts +0 -152
  231. package/test/libs/DYOFinder.spec.ts +0 -194
  232. package/test/libs/player/DTPlayer.element.double.ts +0 -55
  233. package/test/libs/player/DTPlayer.element.spec.ts +0 -28
  234. package/test/libs/player/DTPlayer.manager.double.ts +0 -92
  235. package/test/libs/player/DTPlayer.manager.spec.ts +0 -178
  236. package/tsconfig.dev.json +0 -22
  237. package/tsconfig.json +0 -21
  238. /package/{dist/types/index.d.ts → types/index.js} +0 -0
  239. /package/{dist/types → types}/player.js.map +0 -0
@@ -1,138 +0,0 @@
1
- import {DTComponent, DTModule} from "../../src";
2
- import {mockOverriddenMethods} from "./DTComponent.double";
3
- import {afterEach, beforeEach, describe, expect, jest, test} from "@jest/globals";
4
- import {DTModuleTest, IDTest, KeyTest} from "./DTModule.double";
5
- import MockedFunction = jest.MockedFunction;
6
-
7
- /** ****************** MOCK DEPENDENCIES
8
- * Dependencies used by the component are mocked with Jest
9
- * **** */
10
- jest.mock('../../src/core/DTComponent');
11
- jest.mock('../../src/core/DTError');
12
- // Add specific mock for inherited methods to have a basic implementation
13
- mockOverriddenMethods(DTComponent);
14
-
15
- /** *********************** TESTS SUITES ****************************** */
16
- describe('class DYOToolsModule', () => {
17
- let moduleTest: DTModuleTest;
18
-
19
- beforeEach(() => {
20
- moduleTest = new DTModuleTest();
21
- moduleTest.th_set_id(IDTest);
22
- moduleTest.th_set_key(KeyTest);
23
- });
24
-
25
- afterEach(() => {
26
- jest.resetAllMocks();
27
- });
28
-
29
- describe('inheritance', () => {
30
- test('check good inheritance for class', () => {
31
- expect(DTModule.prototype instanceof DTComponent).toBeTruthy();
32
- });
33
- });
34
-
35
- describe('_componentType', () => {
36
- test('componentType must be "action"', () => {
37
- expect(moduleTest.th_get_componentType()).toBe('module');
38
- });
39
- });
40
-
41
- describe('constructor()', () => {
42
- beforeEach(() => {
43
- jest.resetAllMocks();
44
- });
45
-
46
- test('simple creation with key', () => {
47
- const newModule = new DTModuleTest(KeyTest);
48
- const parentConstructorMock = (DTComponent.prototype.constructor as MockedFunction<(key: string, options: any) => void>).mock;
49
-
50
- expect(parentConstructorMock.calls.length).toBe(1);
51
- expect(parentConstructorMock.calls[0][0]).toBe(KeyTest);
52
-
53
- expect(newModule.th_get_enabled()).toStrictEqual(true);
54
- });
55
- });
56
-
57
- describe('getMaster()', () => {
58
- test('call get context with master accessor', () => {
59
- moduleTest.getMaster();
60
-
61
- expect((moduleTest.getContext as any).mock.calls.length).toBe(1);
62
- expect((moduleTest.getContext as any).mock.calls[0][0]).toBe('master');
63
- });
64
- });
65
-
66
- describe('isEnabled()', () => {
67
- test('return true if the module is enabled', () => {
68
- const enabledModule = moduleTest.isEnabled();
69
-
70
- expect(enabledModule).toBe(true);
71
- });
72
-
73
- test('return false if the module is disabled', () => {
74
- moduleTest.th_set_enabled(false);
75
-
76
- const enabledModule = moduleTest.isEnabled();
77
-
78
- expect(enabledModule).toBe(false);
79
- });
80
- });
81
-
82
- describe('enable()', () => {
83
- test('change enable to true', () => {
84
- moduleTest.th_set_enabled(false);
85
-
86
- moduleTest.enable();
87
-
88
- expect(moduleTest.th_get_enabled()).toBe(true);
89
- });
90
- });
91
-
92
- describe('disable()', () => {
93
- test('change enable to false', () => {
94
- moduleTest.th_set_enabled(true);
95
-
96
- moduleTest.disable();
97
-
98
- expect(moduleTest.th_get_enabled()).toBe(false);
99
- });
100
- });
101
-
102
- describe('toString()', () => {
103
- test('string output standard', () => {
104
- const toStringAction = moduleTest.toString();
105
-
106
- expect(toStringAction).toBe(`Component ${KeyTest} - Type: Module`);
107
- });
108
-
109
- test('string output standard when disabled', () => {
110
- moduleTest.th_set_enabled(false);
111
-
112
- const toStringAction = moduleTest.toString();
113
-
114
- expect(toStringAction).toBe(`Component ${KeyTest} - Type: Module - Disabled`);
115
- });
116
- });
117
-
118
- describe('toObject()', () => {
119
- test('toObject output standard', () => {
120
- const toObjectAction: any = moduleTest.toObject();
121
-
122
- expect(Object.keys(toObjectAction)).toStrictEqual(['id', 'key', 'type', 'enabled']);
123
- expect(toObjectAction.id).toBe(IDTest);
124
- expect(toObjectAction.key).toBe(KeyTest);
125
- expect(toObjectAction.type).toBe('module');
126
- expect(toObjectAction.enabled).toBe(true);
127
- });
128
-
129
- test('toObject output standard when disabled', () => {
130
- moduleTest.th_set_enabled(false);
131
-
132
- const toObjectAction: any = moduleTest.toObject();
133
-
134
- expect(Object.keys(toObjectAction)).toStrictEqual(['id', 'key', 'type', 'enabled']);
135
- expect(toObjectAction.enabled).toBe(false);
136
- });
137
- });
138
- });
@@ -1,243 +0,0 @@
1
- import {
2
- describe, expect, jest, test,
3
- } from '@jest/globals';
4
- import { DTBunch, DTElement, DTPlayer } from '../../src';
5
- import { DTComponentStub } from './DTComponent.double';
6
- import {OwnerTest} from './DTComponentPhysical.double';
7
- import {
8
- BunchMetaData, HaileiMetaData, IMetaDataTest, PlayerMetaData,
9
- } from './DTComponentWithMeta.double';
10
- import { defaultOptions, KeyTest } from './DTBunch.double';
11
- import { DTErrorStub } from './DTError.double';
12
-
13
- /**
14
- * Special test suite for copy overridden method
15
- * Unfortunately copy is very hard to mock correctly in Javascript, due to constructor mocks
16
- * These test doesn't handle the DOC
17
- * Mock for :
18
- * - DTBunch
19
- * - DTElement
20
- * - DTPlayer
21
- */
22
-
23
- describe('Inherited method copy', () => {
24
- describe('DTBunch copy()', () => {
25
- afterEach(() => {
26
- jest.resetAllMocks();
27
- });
28
-
29
- test('copy a bunch - simple case with id and key', () => {
30
- const bunch = new DTBunch(KeyTest);
31
- const bunchCopy = bunch.copy();
32
-
33
- expect(bunch.getId() === bunchCopy.getId()).toBeFalsy();
34
- expect(bunch.getKey() === bunchCopy.getKey()).toBeTruthy();
35
- });
36
-
37
- test('copy a bunch - not copy owner and context', () => {
38
- const bunch = new DTBunch(KeyTest);
39
- jest.spyOn(bunch, 'setContext').mockImplementation(function (context) {
40
- this._context = context;
41
- });
42
- jest.spyOn(bunch, 'setOwner').mockImplementation(function (owner) {
43
- this._owner = owner;
44
- });
45
-
46
- bunch.setContext(new DTComponentStub());
47
- bunch.setOwner(OwnerTest);
48
-
49
- const bunchCopy = bunch.copy();
50
- jest.spyOn(bunchCopy, 'getContext').mockImplementation(function () {
51
- return this._context;
52
- });
53
- jest.spyOn(bunchCopy, 'getOwner').mockImplementation(function () {
54
- return this._owner;
55
- });
56
-
57
- expect(bunchCopy.getContext()).toBeUndefined();
58
- expect(bunchCopy.getOwner()).toBeUndefined();
59
- });
60
-
61
- test('copy a bunch - copy meta-data and globalOptions', () => {
62
- const copiedOptions = {
63
- inheritOwner: true,
64
- replaceIndex: true,
65
- virtualContainer: true,
66
- };
67
- const bunch = new DTBunch('', [], copiedOptions);
68
- jest.spyOn(bunch, 'getManyMeta').mockImplementation(() => BunchMetaData);
69
-
70
- const bunchCopy = bunch.copy();
71
-
72
- expect(bunchCopy.getManyMeta()).toStrictEqual(BunchMetaData);
73
- expect(bunchCopy.getOptions()).toStrictEqual({
74
- ...defaultOptions,
75
- ...copiedOptions,
76
- });
77
- });
78
-
79
- test('copy a bunch - empty errors', () => {
80
- const bunch = new DTBunch(KeyTest, [], { errors: true });
81
- bunch.triggerError(new DTErrorStub());
82
- bunch.triggerError(new DTErrorStub());
83
-
84
- const bunchCopy = bunch.copy();
85
-
86
- expect(bunchCopy.getErrors().length).toBe(0);
87
- });
88
-
89
- test('copy a bunch with items - default case', () => {
90
- const items: Array<DTElement<IMetaDataTest>> = [
91
- new DTElement(),
92
- new DTElement(),
93
- new DTElement(),
94
- ];
95
- jest.spyOn(items[0], 'copy');
96
- jest.spyOn(items[1], 'copy');
97
- jest.spyOn(items[2], 'copy');
98
- const bunch = new DTBunch<DTElement<IMetaDataTest>, IMetaDataTest>(KeyTest, items);
99
-
100
- const bunchCopy = bunch.copy();
101
-
102
- expect(bunchCopy.getAll().length).toBe(3);
103
- expect((items[0].copy as any).mock.calls.length).toBe(1);
104
- expect((items[1].copy as any).mock.calls.length).toBe(1);
105
- expect((items[2].copy as any).mock.calls.length).toBe(1);
106
- });
107
-
108
- test('copy a bunch with items - virtual context case', () => {
109
- const items: Array<DTElement<IMetaDataTest>> = [
110
- new DTElement(),
111
- new DTElement(),
112
- new DTElement(),
113
- ];
114
- jest.spyOn(items[0], 'copy');
115
- jest.spyOn(items[1], 'copy');
116
- jest.spyOn(items[2], 'copy');
117
- const bunch = new DTBunch<DTElement<IMetaDataTest>, IMetaDataTest>(KeyTest, items, { virtualContainer: true });
118
-
119
- const bunchCopy = bunch.copy();
120
-
121
- expect(bunchCopy.getAll().length).toBe(3);
122
- expect((items[0].copy as any).mock.calls.length).toBe(0);
123
- expect((items[1].copy as any).mock.calls.length).toBe(0);
124
- expect((items[2].copy as any).mock.calls.length).toBe(0);
125
- });
126
- });
127
-
128
- describe('DTElement copy()', () => {
129
- afterEach(() => {
130
- jest.resetAllMocks();
131
- });
132
-
133
- test('copy an element - simple case with id and key', () => {
134
- const element = new DTElement(KeyTest);
135
- const elementCopy = element.copy();
136
-
137
- expect(element.getId() === elementCopy.getId()).toBeFalsy();
138
- expect(element.getKey() === elementCopy.getKey()).toBeTruthy();
139
- });
140
-
141
- test('copy an element - not copy context', () => {
142
- const element = new DTElement(KeyTest);
143
- jest.spyOn(element, 'setContext').mockImplementation(function (context) {
144
- this._context = context;
145
- });
146
-
147
- element.setContext(new DTComponentStub());
148
-
149
- const elementCopy = element.copy();
150
- jest.spyOn(elementCopy, 'getContext').mockImplementation(function () {
151
- return this._context;
152
- });
153
-
154
- expect(elementCopy.getContext()).toBeUndefined();
155
- });
156
-
157
- test('copy an element - not copy container', () => {
158
- const element = new DTElement(KeyTest);
159
- jest.spyOn(element, 'setContainer').mockImplementation(function (container) {
160
- this._container = container;
161
- });
162
-
163
- element.setContext(new DTComponentStub());
164
-
165
- const elementCopy = element.copy();
166
- jest.spyOn(elementCopy, 'getContainer').mockImplementation(function () {
167
- return this._container;
168
- });
169
-
170
- expect(elementCopy.getContainer()).toBeUndefined();
171
- });
172
-
173
- test('copy an element - copy meta-data and options', () => {
174
- const element = new DTElement(KeyTest, { errors: true });
175
- jest.spyOn(element, 'getManyMeta').mockImplementation(() => HaileiMetaData);
176
-
177
- const elementCopy = element.copy();
178
-
179
- expect(elementCopy.getManyMeta()).toStrictEqual(HaileiMetaData);
180
- expect(elementCopy.getOptions()).toStrictEqual({ errors: true });
181
- });
182
-
183
- test('copy an element - empty errors', () => {
184
- const element = new DTElement(KeyTest, { errors: true });
185
- element.triggerError(new DTErrorStub());
186
- element.triggerError(new DTErrorStub());
187
-
188
- const elementCopy = element.copy();
189
-
190
- expect(elementCopy.getErrors().length).toBe(0);
191
- });
192
- });
193
-
194
- describe('DTPlayer copy()', () => {
195
- afterEach(() => {
196
- jest.resetAllMocks();
197
- });
198
-
199
- test('copy a player - simple case with id and key', () => {
200
- const player = new DTPlayer(KeyTest);
201
- const playerCopy = player.copy();
202
-
203
- expect(player.getId() === playerCopy.getId()).toBeFalsy();
204
- expect(player.getKey() === playerCopy.getKey()).toBeTruthy();
205
- });
206
-
207
- test('copy a player - not copy context', () => {
208
- const player = new DTPlayer(KeyTest);
209
- jest.spyOn(player, 'setContext').mockImplementation(function (context) {
210
- this._context = context;
211
- });
212
-
213
- player.setContext(new DTComponentStub());
214
-
215
- const playerCopy = player.copy();
216
- jest.spyOn(playerCopy, 'getContext').mockImplementation(function () {
217
- return this._context;
218
- });
219
-
220
- expect(playerCopy.getContext()).toBeUndefined();
221
- });
222
-
223
- test('copy a player - copy meta-data and options', () => {
224
- const player = new DTPlayer(KeyTest, { errors: true });
225
- jest.spyOn(player, 'getManyMeta').mockImplementation(() => PlayerMetaData);
226
-
227
- const playerCopy = player.copy();
228
-
229
- expect(playerCopy.getManyMeta()).toStrictEqual(PlayerMetaData);
230
- expect(playerCopy.getOptions()).toStrictEqual({ errors: true });
231
- });
232
-
233
- test('copy a player - empty errors', () => {
234
- const player = new DTPlayer(KeyTest, { errors: true });
235
- player.triggerError(new DTErrorStub());
236
- player.triggerError(new DTErrorStub());
237
-
238
- const playerCopy = player.copy();
239
-
240
- expect(playerCopy.getErrors().length).toBe(0);
241
- });
242
- });
243
- });
@@ -1,152 +0,0 @@
1
- import { DYOFinderConfiguration, FilterOperatorType } from '../../src/types';
2
- import DYOFinder from '../../src/libs/DYOFinder';
3
- import { DTBunchStub } from '../core/DTBunch.double';
4
- import { DTElementStubExtended } from '../core/DTElement.double';
5
-
6
- /** ****************** STUB PROPERTIES CONSTANTS
7
- * Fixed properties to use with double classes, avoid auto generated and easy checking on test
8
- * **** */
9
- const baseOperators = [
10
- FilterOperatorType.EQ,
11
- FilterOperatorType.IN,
12
- FilterOperatorType.NIN,
13
- FilterOperatorType.NE,
14
- ];
15
-
16
- export const DefaultConfiguration: DYOFinderConfiguration = {
17
- propString: {
18
- operators: baseOperators,
19
- getValue: (item: any) => item.getPropString(),
20
- objectSearch: false,
21
- },
22
- propArray: {
23
- operators: [...baseOperators, FilterOperatorType.CONTAINS, FilterOperatorType.NCONTAINS],
24
- getValue: (item: any) => item.getPropArray(),
25
- objectSearch: false,
26
- },
27
- propNumber: {
28
- operators: [...baseOperators, FilterOperatorType.LTE, FilterOperatorType.GTE],
29
- getValue: (item: any) => item.getPropNumber(),
30
- objectSearch: false,
31
- },
32
- propBoolean: {
33
- operators: baseOperators,
34
- getValue: (item: any) => item.getPropBoolean(),
35
- objectSearch: false,
36
- },
37
- propObject: {
38
- operators: baseOperators,
39
- getValue: (item: any) => item.getPropObject(),
40
- objectSearch: false,
41
- },
42
- propMeta: {
43
- operators: baseOperators,
44
- getValue: (item: any) => item.getPropMeta(),
45
- objectSearch: true,
46
- },
47
- };
48
-
49
- /** ****************** HELPER TEST CLASS
50
- * Helper test class, inherits the main component
51
- * Providing methods to property access and other facilities, in order to avoid using class methods
52
- * **** */
53
- export default class DYOFinderTest extends DYOFinder {
54
- th_get_component(): any {
55
- return this._component;
56
- }
57
-
58
- th_get_configuration(): DYOFinderConfiguration {
59
- return this._configuration;
60
- }
61
-
62
- th_set_configuration(configuration: DYOFinderConfiguration): void {
63
- this._configuration = {
64
- ...this._configuration,
65
- ...configuration,
66
- };
67
- }
68
- }
69
-
70
- /** ****************** STUB CLASS
71
- * Stub class, for using in other component
72
- * **** */
73
-
74
- /** ****************** HELPER METHODS
75
- * Additional helper methods to use with testing
76
- * **** */
77
- export function generateComponent(): DTBunchStub {
78
- const elementFindStubData = [
79
- {
80
- propString: 'item_prime',
81
- propArray: ['tag1', 'tag2'],
82
- propNumber: 17,
83
- propBoolean: true,
84
- propObject: {
85
- data: 'value',
86
- },
87
- propMeta: {
88
- meta1: 'value1',
89
- },
90
- },
91
- {
92
- propString: 'item_prime',
93
- propArray: ['tag1', 'tag2', 'tag3'],
94
- propNumber: 19,
95
- propBoolean: false,
96
- propObject: {
97
- data: 'value',
98
- },
99
- propMeta: {
100
- meta1: 'value1',
101
- meta2: 'value2',
102
- },
103
- },
104
- {
105
- propString: 'item_second',
106
- propArray: ['tag1', 'tag3'],
107
- propNumber: 23,
108
- propBoolean: true,
109
- propObject: {
110
- data: 'value',
111
- },
112
- propMeta: {
113
- meta1: 'value2',
114
- meta2: 'value2',
115
- },
116
- },
117
- {
118
- propString: 'item_third',
119
- propNumber: 17,
120
- propBoolean: false,
121
- propObject: null,
122
- },
123
- {
124
- propString: 'item_second',
125
- propArray: [],
126
- propNumber: 31,
127
- propBoolean: true,
128
- propObject: null,
129
- propMeta: {
130
- meta3: 'value3',
131
- },
132
- },
133
- ];
134
-
135
- const items = [];
136
- let itemIndex = 0;
137
- for (const data of elementFindStubData) {
138
- const elementStub = new DTElementStubExtended();
139
- elementStub.parentIndex = itemIndex;
140
- elementStub.setPropString(data.propString);
141
- elementStub.setPropArray(data.propArray);
142
- elementStub.setPropNumber(data.propNumber);
143
- elementStub.setPropBoolean(data.propBoolean);
144
- elementStub.setPropObject(data.propObject);
145
- elementStub.setPropMeta(data.propMeta);
146
-
147
- items.push(elementStub);
148
- itemIndex += 1;
149
- }
150
-
151
- return new DTBunchStub(items);
152
- }