dyo-tools 0.2.0 → 0.3.2

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 (164) hide show
  1. package/dist/constants.js +4 -4
  2. package/dist/constants.js.map +1 -1
  3. package/dist/core/DTAction.d.ts +10 -0
  4. package/dist/core/DTAction.js +24 -0
  5. package/dist/core/DTAction.js.map +1 -0
  6. package/dist/core/DTBunch.d.ts +6 -7
  7. package/dist/core/DTBunch.js +17 -14
  8. package/dist/core/DTBunch.js.map +1 -1
  9. package/dist/core/DTComponentPhysical.d.ts +7 -4
  10. package/dist/core/DTComponentPhysical.js +6 -0
  11. package/dist/core/DTComponentPhysical.js.map +1 -1
  12. package/dist/core/DTElement.d.ts +5 -0
  13. package/dist/core/DTElement.js +12 -2
  14. package/dist/core/DTElement.js.map +1 -1
  15. package/dist/core/DTManager.d.ts +3 -1
  16. package/dist/core/DTManager.js +24 -14
  17. package/dist/core/DTManager.js.map +1 -1
  18. package/dist/core/DTMaster.d.ts +24 -0
  19. package/dist/core/DTMaster.js +133 -0
  20. package/dist/core/DTMaster.js.map +1 -0
  21. package/dist/core/DTModule.d.ts +14 -0
  22. package/dist/core/DTModule.js +39 -0
  23. package/dist/core/DTModule.js.map +1 -0
  24. package/dist/index.d.ts +5 -1
  25. package/dist/index.js +11 -3
  26. package/dist/index.js.map +1 -1
  27. package/dist/libs/player/DTPlayer.element.d.ts +5 -0
  28. package/dist/libs/player/DTPlayer.element.js +11 -0
  29. package/dist/libs/player/DTPlayer.element.js.map +1 -0
  30. package/dist/libs/player/DTPlayer.manager.d.ts +11 -0
  31. package/dist/libs/player/DTPlayer.manager.js +42 -0
  32. package/dist/libs/player/DTPlayer.manager.js.map +1 -0
  33. package/dist/tsconfig.tsbuildinfo +1 -1
  34. package/dist/types/core.d.ts +103 -0
  35. package/dist/types/core.js +15 -0
  36. package/dist/types/core.js.map +1 -0
  37. package/dist/types/index.d.ts +2 -98
  38. package/dist/types/index.js +16 -12
  39. package/dist/types/index.js.map +1 -1
  40. package/dist/types/player.d.ts +5 -0
  41. package/dist/types/player.js +3 -0
  42. package/dist/types/player.js.map +1 -0
  43. package/docs/assets/highlight.css +29 -29
  44. package/docs/assets/main.js +4 -3
  45. package/docs/assets/navigation.js +1 -0
  46. package/docs/assets/search.js +1 -1
  47. package/docs/assets/style.css +72 -25
  48. package/docs/classes/core_DTAction.DYOToolsAction.html +89 -0
  49. package/docs/classes/core_DTBunch.DYOToolsBunch.html +254 -0
  50. package/docs/classes/core_DTComponent.DYOToolsComponent.html +76 -0
  51. package/docs/classes/core_DTComponentPhysical.DYOToolsComponentPhysical.html +110 -0
  52. package/docs/classes/core_DTComponentWithMeta.DYOToolsComponentWithMeta.html +96 -0
  53. package/docs/classes/core_DTElement.DYOToolsElement.html +135 -0
  54. package/docs/classes/core_DTError.DYOToolsError.html +37 -0
  55. package/docs/classes/core_DTManager.DYOToolsManager.html +237 -0
  56. package/docs/classes/core_DTMaster.DYOToolsMaster.html +150 -0
  57. package/docs/classes/core_DTModule.DYOToolsModule.html +92 -0
  58. package/docs/classes/libs_DYOFinder.DYOFinder.html +34 -0
  59. package/docs/classes/libs_player_DTPlayer_element.DYOToolsPlayer.html +134 -0
  60. package/docs/classes/libs_player_DTPlayer_manager.DYOToolsPlayerManager.html +243 -0
  61. package/docs/enums/types_core.FilterOperatorType.html +10 -0
  62. package/docs/hierarchy.html +1 -0
  63. package/docs/index.html +1 -46
  64. package/docs/interfaces/types_core.DTBunchFilters.html +6 -0
  65. package/docs/interfaces/types_core.DTBunchOptions.html +19 -0
  66. package/docs/interfaces/types_core.DTBunchToObject.html +7 -0
  67. package/docs/interfaces/types_core.DTComponentOptions.html +5 -0
  68. package/docs/interfaces/types_core.DTComponentToObject.html +4 -0
  69. package/docs/interfaces/types_core.DTElementToObject.html +7 -0
  70. package/docs/interfaces/types_core.DTManagerFilters.html +6 -0
  71. package/docs/interfaces/types_core.DTManagerOptions.html +8 -0
  72. package/docs/interfaces/types_core.DTManagerToObject.html +5 -0
  73. package/docs/interfaces/types_core.DTMasterToObject.html +8 -0
  74. package/docs/interfaces/types_core.DTModuleToObject.html +6 -0
  75. package/docs/interfaces/types_core.DYOFinderConfigurationPropDefault.html +4 -0
  76. package/docs/interfaces/types_core.DYOFinderConfigurationPropObjectSearch.html +4 -0
  77. package/docs/interfaces/types_core.DYOFinderFilterOperatorAdvanced.html +5 -0
  78. package/docs/interfaces/types_core.DYOFinderFilterOperatorBase.html +5 -0
  79. package/docs/interfaces/types_player.DTPlayerManagerSimpleConfiguration.html +3 -0
  80. package/docs/modules/constants.html +6 -0
  81. package/docs/modules/core_DTAction.html +2 -0
  82. package/docs/modules/core_DTBunch.html +2 -0
  83. package/docs/modules/core_DTComponent.html +2 -0
  84. package/docs/modules/core_DTComponentPhysical.html +2 -0
  85. package/docs/modules/core_DTComponentWithMeta.html +2 -0
  86. package/docs/modules/core_DTElement.html +2 -0
  87. package/docs/modules/core_DTError.html +2 -0
  88. package/docs/modules/core_DTManager.html +2 -0
  89. package/docs/modules/core_DTMaster.html +2 -0
  90. package/docs/modules/core_DTModule.html +2 -0
  91. package/docs/modules/libs_DYOFinder.html +2 -0
  92. package/docs/modules/libs_player_DTPlayer_element.html +2 -0
  93. package/docs/modules/libs_player_DTPlayer_manager.html +2 -0
  94. package/docs/modules/types.html +29 -0
  95. package/docs/modules/types_core.html +28 -0
  96. package/docs/modules/types_player.html +2 -0
  97. package/docs/types/types_core.DTAcceptedMetaData.html +2 -0
  98. package/docs/types/types_core.DTManagerItemType.html +1 -0
  99. package/docs/types/types_core.DTManagerItemsType.html +2 -0
  100. package/docs/types/types_core.DYOFinderComponentType.html +1 -0
  101. package/docs/types/types_core.DYOFinderConfiguration.html +2 -0
  102. package/docs/types/types_core.DYOFinderConfigurationProp.html +1 -0
  103. package/docs/types/types_core.DYOFinderFilterOperator.html +1 -0
  104. package/docs/types/types_core.DYOFinderFilterOperatorArgument.html +1 -0
  105. package/docs/types/types_core.DYOFinderFilters.html +1 -0
  106. package/docs/types/types_core.StandardPrimitiveType.html +2 -0
  107. package/docs/types/types_core.StandardPrimitiveTypeWithArray.html +1 -0
  108. package/docs/variables/constants.bunchDefaultOptions.html +2 -0
  109. package/docs/variables/constants.componentBunchDefaultFinderConfiguration.html +1 -0
  110. package/docs/variables/constants.componentManagerDefaultFinderConfiguration.html +1 -0
  111. package/docs/variables/constants.componentPhysicalDefaultFinderConfiguration.html +1 -0
  112. package/docs/variables/constants.managerDefaultOptions.html +2 -0
  113. package/package.json +16 -17
  114. package/src/constants.ts +4 -4
  115. package/src/core/DTAction.ts +52 -0
  116. package/src/core/DTBunch.ts +36 -30
  117. package/src/core/DTComponent.ts +1 -1
  118. package/src/core/DTComponentPhysical.ts +20 -5
  119. package/src/core/DTElement.ts +35 -2
  120. package/src/core/DTManager.ts +37 -18
  121. package/src/core/DTMaster.ts +318 -0
  122. package/src/core/DTModule.ts +90 -0
  123. package/src/index.ts +9 -1
  124. package/src/libs/player/DTPlayer.element.ts +9 -0
  125. package/src/libs/player/DTPlayer.manager.ts +84 -0
  126. package/src/types/core.ts +169 -0
  127. package/src/types/index.ts +2 -162
  128. package/src/types/player.ts +6 -0
  129. package/test/core/DTAction.double.ts +78 -0
  130. package/test/core/DTAction.spec.ts +76 -0
  131. package/test/core/DTBunch.double.ts +18 -10
  132. package/test/core/DTBunch.spec.ts +83 -68
  133. package/test/core/DTComponentPhysical.double.ts +3 -3
  134. package/test/core/DTComponentPhysical.spec.ts +25 -11
  135. package/test/core/DTElement.double.ts +21 -5
  136. package/test/core/DTElement.spec.ts +52 -8
  137. package/test/core/DTError.double.ts +1 -1
  138. package/test/core/DTManager.double.ts +29 -5
  139. package/test/core/DTManager.spec.ts +80 -17
  140. package/test/core/DTMaster.double.ts +141 -0
  141. package/test/core/DTMaster.spec.ts +584 -0
  142. package/test/core/DTModule.double.ts +80 -0
  143. package/test/core/DTModule.spec.ts +138 -0
  144. package/test/core/copy.spec.ts +20 -4
  145. package/test/{core/DTPlayer.double.ts → libs/player/DTPlayer.element.double.ts} +15 -24
  146. package/test/libs/player/DTPlayer.element.spec.ts +28 -0
  147. package/test/libs/player/DTPlayer.manager.double.ts +92 -0
  148. package/test/libs/player/DTPlayer.manager.spec.ts +178 -0
  149. package/LICENSE +0 -21
  150. package/cucumber.js +0 -9
  151. package/dist/core/DTPlayer.d.ts +0 -8
  152. package/dist/core/DTPlayer.js +0 -30
  153. package/dist/core/DTPlayer.js.map +0 -1
  154. package/e2e/0.2.0/epic1.feature +0 -29
  155. package/e2e/0.2.0/epic2.feature +0 -22
  156. package/e2e/0.2.0/epic3.feature +0 -25
  157. package/e2e/0.2.0/resources/dominion.js +0 -195
  158. package/e2e/0.2.0/resources/utils.js +0 -27
  159. package/e2e/0.2.0/support/steps.js +0 -108
  160. package/e2e/future/epic4.feature +0 -39
  161. package/e2e/future/resources/dominion.js +0 -238
  162. package/e2e/future/resources/utils.js +0 -27
  163. package/src/core/DTPlayer.ts +0 -57
  164. package/test/core/DTPlayer.spec.ts +0 -80
@@ -0,0 +1,138 @@
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
+ });
@@ -3,7 +3,7 @@ import {
3
3
  } from '@jest/globals';
4
4
  import { DTBunch, DTElement, DTPlayer } from '../../src';
5
5
  import { DTComponentStub } from './DTComponent.double';
6
- import { DTPlayerStub } from './DTPlayer.double';
6
+ import {OwnerTest} from './DTComponentPhysical.double';
7
7
  import {
8
8
  BunchMetaData, HaileiMetaData, IMetaDataTest, PlayerMetaData,
9
9
  } from './DTComponentWithMeta.double';
@@ -44,7 +44,7 @@ describe('Inherited method copy', () => {
44
44
  });
45
45
 
46
46
  bunch.setContext(new DTComponentStub());
47
- bunch.setOwner(new DTPlayerStub());
47
+ bunch.setOwner(OwnerTest);
48
48
 
49
49
  const bunchCopy = bunch.copy();
50
50
  jest.spyOn(bunchCopy, 'getContext').mockImplementation(function () {
@@ -62,7 +62,7 @@ describe('Inherited method copy', () => {
62
62
  const copiedOptions = {
63
63
  inheritOwner: true,
64
64
  replaceIndex: true,
65
- virtualContext: true,
65
+ virtualContainer: true,
66
66
  };
67
67
  const bunch = new DTBunch('', [], copiedOptions);
68
68
  jest.spyOn(bunch, 'getManyMeta').mockImplementation(() => BunchMetaData);
@@ -114,7 +114,7 @@ describe('Inherited method copy', () => {
114
114
  jest.spyOn(items[0], 'copy');
115
115
  jest.spyOn(items[1], 'copy');
116
116
  jest.spyOn(items[2], 'copy');
117
- const bunch = new DTBunch<DTElement<IMetaDataTest>, IMetaDataTest>(KeyTest, items, { virtualContext: true });
117
+ const bunch = new DTBunch<DTElement<IMetaDataTest>, IMetaDataTest>(KeyTest, items, { virtualContainer: true });
118
118
 
119
119
  const bunchCopy = bunch.copy();
120
120
 
@@ -154,6 +154,22 @@ describe('Inherited method copy', () => {
154
154
  expect(elementCopy.getContext()).toBeUndefined();
155
155
  });
156
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
+
157
173
  test('copy an element - copy meta-data and options', () => {
158
174
  const element = new DTElement(KeyTest, { errors: true });
159
175
  jest.spyOn(element, 'getManyMeta').mockImplementation(() => HaileiMetaData);
@@ -1,18 +1,20 @@
1
- import {DTPlayer} from '../../src';
2
- import {IMetaDataTest} from './DTComponentWithMeta.double';
1
+ import {DTPlayer} from '../../../src';
3
2
 
4
3
  /******************** STUB PROPERTIES CONSTANTS
5
4
  * Fixed properties to use with double classes, avoid auto generated and easy checking on test
6
5
  * *****/
7
6
  export const IDTest = 'DTPlayer-id-1234567';
8
7
  export const KeyTest = 'DTPlayer-key-1234567';
9
- export const toStringTest = 'DTPlayer Stub toString';
8
+
9
+ // Specific elements constants
10
+ export const KeyTest1 = 'DTPlayer-key-1234567-1';
11
+ export const KeyTest2 = 'DTPlayer-key-1234567-2';
10
12
 
11
13
  /******************** HELPER TEST CLASS
12
14
  * Helper test class, inherits the main component
13
15
  * Providing methods to property access and other facilities, in order to avoid using class methods
14
16
  * *****/
15
- export class DTPlayerTest extends DTPlayer<IMetaDataTest> {
17
+ export class DTPlayerTest extends DTPlayer {
16
18
  th_get_id(): string {
17
19
  return this._id;
18
20
  }
@@ -29,36 +31,25 @@ export class DTPlayerTest extends DTPlayer<IMetaDataTest> {
29
31
  this._key = key;
30
32
  }
31
33
 
32
- th_get_componentType(): string {
33
- return this._componentType;
34
- }
35
-
36
- th_set_meta(meta: IMetaDataTest): void {
37
- this._meta = meta;
34
+ th_get_domain(): string {
35
+ return this._domain;
38
36
  }
39
37
  }
40
38
 
41
- /******************** STUB CLASS
39
+ /** ****************** STUB CLASS
42
40
  * Stub class, for using in other component
43
- * *****/
44
- export class DTPlayerStub extends DTPlayer<{}> {
45
- constructor() {
46
- super();
41
+ * **** */
42
+ export class DTPlayerStub extends DTPlayerTest {
43
+ constructor(key: string) {
44
+ super(key);
45
+ this._key = key;
47
46
  this._id = IDTest;
48
- this._key = KeyTest;
49
- }
50
-
51
- getKey(): string {
52
- return KeyTest;
53
47
  }
54
48
 
55
49
  getId(): string {
56
50
  return IDTest;
57
51
  }
58
-
59
- toString(): string {
60
- return toStringTest;
61
- }
62
52
  }
63
53
 
64
54
 
55
+
@@ -0,0 +1,28 @@
1
+ import {afterEach, beforeEach, describe, expect, jest, test,} from '@jest/globals';
2
+ import {DTPlayerTest} from "./DTPlayer.element.double";
3
+ import {DTElement, DTPlayer} from "../../../src";
4
+
5
+ /** *********************** TESTS SUITES ****************************** */
6
+ describe('class DYOToolsPlayerElement', () => {
7
+ let playerTest: DTPlayerTest;
8
+
9
+ beforeEach(() => {
10
+ playerTest = new DTPlayerTest();
11
+ });
12
+
13
+ afterEach(() => {
14
+ jest.resetAllMocks();
15
+ });
16
+
17
+ describe('inheritance', () => {
18
+ test('check good inheritance for class', () => {
19
+ expect(DTPlayer.prototype instanceof DTElement).toBeTruthy();
20
+ });
21
+ });
22
+
23
+ describe('_domain', () => {
24
+ test('domain must be "player"', () => {
25
+ expect(playerTest.th_get_domain()).toBe('player');
26
+ });
27
+ });
28
+ });
@@ -0,0 +1,92 @@
1
+ import {DTPlayer, DTPlayerManager} from '../../../src';
2
+ import {DTAcceptedMetaData, DTManagerItemsType, DTManagerOptions} from "../../../src/types";
3
+ import {DTBunchStubLibrary} from "../../core/DTBunch.double";
4
+ import {DTPlayerStub} from "./DTPlayer.element.double";
5
+
6
+ /******************** STUB PROPERTIES CONSTANTS
7
+ * Fixed properties to use with double classes, avoid auto generated and easy checking on test
8
+ * *****/
9
+ export const IDTest = 'DTPlayerManager-id-1234567';
10
+ export const KeyTest = 'DTPlayerManager-key-1234567';
11
+
12
+ /******************** HELPER TEST CLASS
13
+ * Helper test class, inherits the main component
14
+ * Providing methods to property access and other facilities, in order to avoid using class methods
15
+ * *****/
16
+ export class DTPlayerManagerTest extends DTPlayerManager {
17
+ th_get_id(): string {
18
+ return this._id;
19
+ }
20
+
21
+ th_set_id(id: string): void {
22
+ this._id = id;
23
+ }
24
+
25
+ th_get_key(): string {
26
+ return this._key;
27
+ }
28
+
29
+ th_set_key(key: string): void {
30
+ this._key = key;
31
+ }
32
+
33
+ th_get_domain(): string {
34
+ return this._domain;
35
+ }
36
+
37
+ th_get_items(): any {
38
+ return this._items;
39
+ }
40
+
41
+ th_set_items(items: DTManagerItemsType<DTPlayer<DTAcceptedMetaData>>): void {
42
+ this._items = items;
43
+ }
44
+
45
+ th_get_single_item(id: string): any {
46
+ return this._items[id];
47
+ }
48
+
49
+ th_get_scopes(): any {
50
+ return this._scopes;
51
+ }
52
+
53
+ th_set_scopes(scopes: any): void {
54
+ this._scopes = scopes;
55
+ }
56
+
57
+ th_get_library(): any {
58
+ return this._library;
59
+ }
60
+
61
+ th_set_library(library: any): void {
62
+ this._library = library;
63
+ }
64
+
65
+ th_get_options(): DTManagerOptions {
66
+ return this._options;
67
+ }
68
+ }
69
+
70
+ /** ****************** HELPER METHODS
71
+ * Additional helper methods to use with testing
72
+ * **** */
73
+ export const populateManager = (manager: DTPlayerManagerTest): DTPlayerManagerTest => {
74
+ const mockedElements = [];
75
+
76
+ // Create players Stubs
77
+ let nbPlayers = 3;
78
+ while (nbPlayers > 0) {
79
+ const player = new DTPlayerStub(`player${nbPlayers}`);
80
+ mockedElements.push(player);
81
+
82
+ nbPlayers--;
83
+ }
84
+
85
+ // Library
86
+ manager.th_set_library(new DTBunchStubLibrary(mockedElements));
87
+
88
+ return manager;
89
+ }
90
+
91
+
92
+
@@ -0,0 +1,178 @@
1
+ import {afterEach, beforeEach, describe, expect, jest, test,} from '@jest/globals';
2
+ import {DTManager, DTPlayer, DTPlayerManager} from "../../../src";
3
+ import {DTPlayerManagerTest} from "./DTPlayer.manager.double";
4
+ import {DTPlayerStub, IDTest, KeyTest, KeyTest1, KeyTest2} from "./DTPlayer.element.double";
5
+ import {managerDefaultOptions} from "../../../src/constants";
6
+
7
+ /** ****************** MOCK DEPENDENCIES
8
+ * Dependencies used by the component are mocked with Jest
9
+ * **** */
10
+ jest.mock('../../../src/libs/player/DTPlayer.element');
11
+ jest.mock('../../../src/core/DTBunch');
12
+
13
+ /** *********************** TESTS SUITES ****************************** */
14
+ describe('class DYOToolsPlayerManager', () => {
15
+ let playerManagerTest: DTPlayerManagerTest;
16
+
17
+ beforeEach(() => {
18
+ playerManagerTest = new DTPlayerManagerTest();
19
+ });
20
+
21
+ afterEach(() => {
22
+ jest.resetAllMocks();
23
+ });
24
+
25
+ describe('inheritance', () => {
26
+ test('check good inheritance for class', () => {
27
+ expect(DTPlayerManager.prototype instanceof DTManager).toBeTruthy();
28
+ });
29
+ });
30
+
31
+ describe('_domain', () => {
32
+ test('domain must be "player"', () => {
33
+ expect(playerManagerTest.th_get_domain()).toBe('player');
34
+ });
35
+ });
36
+
37
+ describe('constructor()', () => {
38
+ beforeEach(() => {
39
+ (DTPlayer.prototype.getKey as any).mockImplementation(function() {
40
+ return this._key;
41
+ })
42
+ });
43
+
44
+ test('creation simple empty manager', () => {
45
+ const newPlayerManager = new DTPlayerManagerTest();
46
+
47
+ expect(newPlayerManager.th_get_key()).toBe('player');
48
+ expect(newPlayerManager.th_get_items()).toStrictEqual({});
49
+ expect(newPlayerManager.th_get_scopes()).toStrictEqual(['default', 'virtual']);
50
+ expect(newPlayerManager.th_get_library()).toBeDefined();
51
+ });
52
+
53
+ test('creation with simple configuration - player number', () => {
54
+ const configuration = {
55
+ players: 3
56
+ }
57
+ const newPlayerManager = new DTPlayerManagerTest(configuration);
58
+
59
+ expect(newPlayerManager.th_get_items()).toStrictEqual({});
60
+
61
+ // Check creation of 3 DTPlayer
62
+ let calls = 3;
63
+ expect((DTPlayer.prototype.constructor as any).mock.calls.length).toBe(calls);
64
+ while (calls > 0) {
65
+ expect((DTPlayer.prototype.constructor as any).mock.calls[calls - 1][0]).toBe(`player${calls}`);
66
+ calls--;
67
+ }
68
+
69
+ // Check adding 3 DTPlayer to library
70
+ expect((newPlayerManager.th_get_library().add as any).mock.calls.length).toBe(3);
71
+ });
72
+
73
+ test('creation with simple configuration - player array', () => {
74
+ const configuration = {
75
+ players: [
76
+ new DTPlayerStub(KeyTest),
77
+ new DTPlayerStub(KeyTest1),
78
+ new DTPlayerStub(KeyTest2),
79
+ ]
80
+ }
81
+ const newPlayerManager = new DTPlayerManagerTest(configuration);
82
+
83
+ expect(newPlayerManager.th_get_items()).toStrictEqual({});
84
+ expect((newPlayerManager.th_get_library().addMany as any).mock.calls.length).toBe(1);
85
+ expect((newPlayerManager.th_get_library().addMany as any).mock.calls[0][0].length).toBe(3);
86
+ expect((newPlayerManager.th_get_library().addMany as any).mock.calls[0][0][0].th_get_key()).toBe(KeyTest);
87
+ expect((newPlayerManager.th_get_library().addMany as any).mock.calls[0][0][1].th_get_key()).toBe(KeyTest1);
88
+ expect((newPlayerManager.th_get_library().addMany as any).mock.calls[0][0][2].th_get_key()).toBe(KeyTest2);
89
+ });
90
+
91
+ test('creation with simple configuration - invalid player number', () => {
92
+ const configuration = {
93
+ players: -3
94
+ }
95
+ const newPlayerManager = new DTPlayerManagerTest(configuration);
96
+
97
+ expect(newPlayerManager.th_get_items()).toStrictEqual({});
98
+
99
+ // No creation and adding
100
+ expect((DTPlayer.prototype.constructor as any).mock.calls.length).toBe(0);
101
+ expect((newPlayerManager.th_get_library().add as any).mock.calls.length).toBe(0);
102
+ });
103
+
104
+ test('creation with simple configuration - errors manager option', () => {
105
+ const configuration = {
106
+ errors: true
107
+ };
108
+ const newPlayerManager = new DTPlayerManagerTest(configuration);
109
+
110
+ expect(newPlayerManager.th_get_options()).toStrictEqual({
111
+ ...managerDefaultOptions,
112
+ errors: true
113
+ });
114
+ });
115
+ });
116
+
117
+ describe('getPlayer()', () => {
118
+ beforeEach(() => {
119
+ jest.spyOn(playerManagerTest, 'getLibrary').mockReturnValue(playerManagerTest.th_get_library());
120
+ });
121
+
122
+ test('alias - call get() of library', () => {
123
+ const library = playerManagerTest.th_get_library();
124
+
125
+ playerManagerTest.getPlayer(IDTest);
126
+
127
+ expect((library.get).mock.calls.length).toBe(1);
128
+ expect((library.get).mock.calls[0][0]).toBe(IDTest);
129
+ });
130
+ });
131
+
132
+ describe('addPlayer()', () => {
133
+ beforeEach(() => {
134
+ jest.spyOn(playerManagerTest, 'getLibrary').mockReturnValue(playerManagerTest.th_get_library());
135
+ });
136
+
137
+ test('alias - call add() of library', () => {
138
+ const library = playerManagerTest.th_get_library();
139
+ const playerToAdd = new DTPlayerStub(KeyTest);
140
+
141
+ playerManagerTest.addPlayer(playerToAdd);
142
+
143
+ expect((library.add).mock.calls.length).toBe(1);
144
+ expect((library.add).mock.calls[0][0]).toStrictEqual(playerToAdd);
145
+ });
146
+ });
147
+
148
+ describe('removePlayer()', () => {
149
+ beforeEach(() => {
150
+ jest.spyOn(playerManagerTest, 'getLibrary').mockReturnValue(playerManagerTest.th_get_library());
151
+ });
152
+
153
+ test('alias - call remove() of library', () => {
154
+ const library = playerManagerTest.th_get_library();
155
+
156
+ playerManagerTest.removePlayer(IDTest);
157
+
158
+ expect((library.remove).mock.calls.length).toBe(1);
159
+ expect((library.remove).mock.calls[0][0]).toBe(IDTest);
160
+ });
161
+ });
162
+
163
+ describe('findPlayers()', () => {
164
+ beforeEach(() => {
165
+ jest.spyOn(playerManagerTest, 'getLibrary').mockReturnValue(playerManagerTest.th_get_library());
166
+ });
167
+
168
+ test('alias - call find() of library', () => {
169
+ const library = playerManagerTest.th_get_library();
170
+ const testFilters = { id: { $eq: IDTest }, key: { $ne: KeyTest } };
171
+
172
+ playerManagerTest.findPlayers(testFilters);
173
+
174
+ expect((library.find).mock.calls.length).toBe(1);
175
+ expect((library.find).mock.calls[0][0]).toStrictEqual(testFilters);
176
+ });
177
+ });
178
+ });
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Flaya24
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/cucumber.js DELETED
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- default: {
3
- parallel: 2,
4
- format: ['html:cucumber-report.html'],
5
- paths: ['e2e/0.2.0/**/*.feature'],
6
- require: ['e2e/0.2.0/support/*.js'],
7
- publishQuiet: true
8
- }
9
- }
@@ -1,8 +0,0 @@
1
- import DYOToolsComponentWithMeta from './DTComponentWithMeta';
2
- import { DTAcceptedMetaData, DTPlayerToObject } from '../types';
3
- export default class DYOToolsPlayer<IComponentMeta extends DTAcceptedMetaData> extends DYOToolsComponentWithMeta<IComponentMeta> {
4
- protected _componentType: string;
5
- copy(): DYOToolsPlayer<IComponentMeta>;
6
- toObject(): DTPlayerToObject<IComponentMeta>;
7
- toString(): string;
8
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const DTComponentWithMeta_1 = require("./DTComponentWithMeta");
4
- class DYOToolsPlayer extends DTComponentWithMeta_1.default {
5
- constructor() {
6
- super(...arguments);
7
- this._componentType = 'player';
8
- }
9
- copy() {
10
- const copyElement = new DYOToolsPlayer(this._key, this._options);
11
- copyElement.setManyMeta(Object.assign({}, this.getManyMeta()));
12
- return copyElement;
13
- }
14
- toObject() {
15
- const objectPlayer = {
16
- id: this._id,
17
- key: this._key,
18
- type: this._componentType,
19
- };
20
- if (this._meta && Object.keys(this._meta).length > 0) {
21
- objectPlayer.meta = Object.assign({}, this.getManyMeta());
22
- }
23
- return objectPlayer;
24
- }
25
- toString() {
26
- return `Component ${this._key} - Type: Player`;
27
- }
28
- }
29
- exports.default = DYOToolsPlayer;
30
- //# sourceMappingURL=DTPlayer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DTPlayer.js","sourceRoot":"","sources":["../../src/core/DTPlayer.ts"],"names":[],"mappings":";;AAAA,+DAA8D;AAG9D,MAAqB,cAA0D,SAAQ,6BAAyC;IAAhI;;QAIY,mBAAc,GAAG,QAAQ,CAAC;IAiDtC,CAAC;IAxCC,IAAI;QACF,MAAM,WAAW,GAAG,IAAI,cAAc,CAAiB,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjF,WAAW,CAAC,WAAW,mBAAM,IAAI,CAAC,WAAW,EAAE,EAAG,CAAC;QAEnD,OAAO,WAAW,CAAC;IACrB,CAAC;IAaD,QAAQ;QACN,MAAM,YAAY,GAAqC;YACrD,EAAE,EAAE,IAAI,CAAC,GAAG;YACZ,GAAG,EAAE,IAAI,CAAC,IAAI;YACd,IAAI,EAAE,IAAI,CAAC,cAAc;SAC1B,CAAC;QAEF,IAAI,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YACpD,YAAY,CAAC,IAAI,qBAAQ,IAAI,CAAC,WAAW,EAAE,CAAE,CAAC;SAC/C;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAOD,QAAQ;QACN,OAAO,aAAa,IAAI,CAAC,IAAI,iBAAiB,CAAC;IACjD,CAAC;CACF;AArDD,iCAqDC"}
@@ -1,29 +0,0 @@
1
- Feature: Epic 1 - Manager and bunches
2
-
3
- Scenario: Store of bunches
4
- Given my empty manager
5
- When I add 5 physical bunches and 2 virtual bunches
6
- Then I should have 7 bunches in my manager
7
-
8
- Scenario: No duplicated bunches
9
- Given my dominion manager
10
- When I add an already existing bunch
11
- Then I should see an error "id_conflict"
12
-
13
- Scenario: Easy finding of bunch
14
- Given my dominion manager
15
- Then I should find my current hand
16
- And I should find 2 bunches with
17
- | key | hand |
18
- And I should find 5 bunches with
19
- | owner | PRIAM |
20
- And I should find 2 bunches with
21
- | cost | 4 |
22
-
23
- Scenario: Bunch removal
24
- Given my dominion manager
25
- When I remove my current hand
26
- Then I shouldn't find my current hand
27
- And I should find 1 bunches with
28
- | key | hand |
29
-