@adaas/a-concept 0.1.17 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js +22 -7
- package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.meta.js +2 -1
- package/dist/src/global/A-Component/A-Component.meta.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.types.d.ts +2 -11
- package/dist/src/global/A-Concept/A-Concept.types.d.ts +4 -21
- package/dist/src/global/A-Container/A-Container.meta.js +4 -2
- package/dist/src/global/A-Container/A-Container.meta.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.types.d.ts +2 -11
- package/dist/src/global/A-Context/A-Context.class.d.ts +8 -0
- package/dist/src/global/A-Context/A-Context.class.js +30 -2
- package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature-Define.decorator.js +1 -1
- package/dist/src/global/A-Feature/A-Feature-Define.decorator.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js +27 -8
- package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.class.d.ts +2 -1
- package/dist/src/global/A-Feature/A-Feature.class.js +7 -3
- package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.types.d.ts +69 -27
- package/dist/src/global/A-Stage/A-Stage.class.d.ts +37 -28
- package/dist/src/global/A-Stage/A-Stage.class.js +62 -98
- package/dist/src/global/A-Stage/A-Stage.class.js.map +1 -1
- package/dist/src/global/A-Stage/A-Stage.types.d.ts +30 -3
- package/dist/src/global/A-Stage/A-Stage.types.js.map +1 -1
- package/dist/src/global/A-StepManager/A-StepManager.class.d.ts +20 -0
- package/dist/src/{helpers/A_StepsManager.class.js → global/A-StepManager/A-StepManager.class.js} +38 -64
- package/dist/src/global/A-StepManager/A-StepManager.class.js.map +1 -0
- package/dist/src/global/A-StepManager/A-StepManager.error.d.ts +4 -0
- package/dist/src/global/A-StepManager/A-StepManager.error.js +9 -0
- package/dist/src/global/A-StepManager/A-StepManager.error.js.map +1 -0
- package/index.ts +2 -1
- package/package.json +3 -3
- package/src/global/A-Abstraction/A-Abstraction-Extend.decorator.ts +27 -7
- package/src/global/A-Component/A-Component.meta.ts +2 -1
- package/src/global/A-Component/A-Component.types.ts +2 -11
- package/src/global/A-Concept/A-Concept.types.ts +4 -21
- package/src/global/A-Container/A-Container.meta.ts +4 -2
- package/src/global/A-Container/A-Container.types.ts +2 -11
- package/src/global/A-Context/A-Context.class.ts +40 -3
- package/src/global/A-Feature/A-Feature-Define.decorator.ts +1 -0
- package/src/global/A-Feature/A-Feature-Extend.decorator.ts +34 -8
- package/src/global/A-Feature/A-Feature.class.ts +8 -1
- package/src/global/A-Feature/A-Feature.types.ts +80 -33
- package/src/global/A-Stage/A-Stage.class.ts +71 -143
- package/src/global/A-Stage/A-Stage.types.ts +34 -3
- package/src/{helpers/A_StepsManager.class.ts → global/A-StepManager/A-StepManager.class.ts} +53 -87
- package/src/global/A-StepManager/A-StepManager.error.ts +10 -0
- package/tests/A-Abstraction.test.ts +274 -190
- package/tests/A-Feature.test.ts +84 -1
- package/tests/A-StepManager.test.ts +346 -0
- package/dist/src/helpers/A_StepsManager.class.d.ts +0 -35
- package/dist/src/helpers/A_StepsManager.class.js.map +0 -1
|
@@ -3,198 +3,202 @@ import './test.setup'
|
|
|
3
3
|
import { A_Concept } from '@adaas/a-concept/global/A-Concept/A-Concept.class';
|
|
4
4
|
import { A_Container } from '@adaas/a-concept/global/A-Container/A-Container.class';
|
|
5
5
|
import { A_Context } from '@adaas/a-concept/global/A-Context/A-Context.class';
|
|
6
|
+
import { A_Scope } from '@adaas/a-concept/global/A-Scope/A-Scope.class';
|
|
7
|
+
import { A_TYPES__ConceptAbstractions } from '@adaas/a-concept/global/A-Concept/A-Concept.constants';
|
|
8
|
+
import { A_Inject } from '@adaas/a-concept/global/A-Inject/A-Inject.decorator';
|
|
9
|
+
import { A_Feature } from '@adaas/a-concept/global/A-Feature/A-Feature.class';
|
|
6
10
|
|
|
7
11
|
jest.retryTimes(0);
|
|
8
12
|
|
|
9
13
|
describe('A-Abstraction Tests', () => {
|
|
10
|
-
it('It should be possible to extend abstraction on A-Component level', async () => {
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
// it('It should be possible to extend abstraction on A-Component level', async () => {
|
|
15
|
+
// class MyComponent extends A_Component {
|
|
16
|
+
// private _test: number = 0
|
|
17
|
+
|
|
18
|
+
// @A_Concept.Load()
|
|
19
|
+
// myMethod() {
|
|
20
|
+
// this._test++;
|
|
21
|
+
// }
|
|
22
|
+
// }
|
|
23
|
+
// });
|
|
24
|
+
|
|
25
|
+
// it('It should be possible to extend abstraction on A-Container level', async () => {
|
|
26
|
+
// class MyContainer extends A_Container {
|
|
27
|
+
// private _test: number = 0
|
|
28
|
+
|
|
29
|
+
// @A_Concept.Load()
|
|
30
|
+
// myMethod() {
|
|
31
|
+
// this._test++;
|
|
32
|
+
// }
|
|
33
|
+
// }
|
|
34
|
+
// });
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// it('It should be possible to proceed Concept Abstraction', async () => {
|
|
38
|
+
// class MyComponent extends A_Component {
|
|
39
|
+
// _test2: number = 0
|
|
40
|
+
|
|
41
|
+
// @A_Concept.Load()
|
|
42
|
+
// myMethod() {
|
|
43
|
+
// this._test2++;
|
|
44
|
+
// }
|
|
45
|
+
// }
|
|
46
|
+
|
|
47
|
+
// class MyContainer extends A_Container {
|
|
48
|
+
// _test: number = 0
|
|
49
|
+
|
|
50
|
+
// @A_Concept.Load()
|
|
51
|
+
// myMethod() {
|
|
52
|
+
// this._test++;
|
|
53
|
+
// }
|
|
54
|
+
// }
|
|
55
|
+
|
|
56
|
+
// const myContainer = new MyContainer({
|
|
57
|
+
// name: 'MyContainer',
|
|
58
|
+
// components: [MyComponent]
|
|
59
|
+
// });
|
|
60
|
+
|
|
61
|
+
// const testConcept = new A_Concept({
|
|
62
|
+
// name: 'TestConcept',
|
|
63
|
+
// containers: [myContainer]
|
|
64
|
+
// });
|
|
65
|
+
|
|
66
|
+
// await testConcept.load();
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
// const resolvedComponent = myContainer.scope.resolve(MyComponent);
|
|
70
|
+
|
|
71
|
+
// expect(resolvedComponent).toBeInstanceOf(MyComponent);
|
|
72
|
+
// expect(myContainer._test).toBe(1);
|
|
73
|
+
// expect(resolvedComponent._test2).toBe(1);
|
|
74
|
+
|
|
75
|
+
// });
|
|
76
|
+
// it('Should allow to extend abstraction with multiple containers', async () => {
|
|
77
|
+
// A_Context.reset();
|
|
78
|
+
|
|
79
|
+
// class MyContainerA extends A_Container {
|
|
80
|
+
// _test: number = 0
|
|
81
|
+
|
|
82
|
+
// @A_Concept.Load()
|
|
83
|
+
// myMethod() {
|
|
84
|
+
// this._test++;
|
|
85
|
+
// }
|
|
86
|
+
// }
|
|
87
|
+
// class MyContainerB extends A_Container {
|
|
88
|
+
// _test: number = 0
|
|
89
|
+
|
|
90
|
+
// @A_Concept.Load()
|
|
91
|
+
// myMethod() {
|
|
92
|
+
// this._test++;
|
|
93
|
+
// }
|
|
94
|
+
// }
|
|
95
|
+
|
|
96
|
+
// const containerA = new MyContainerA({ name: 'ContainerA' });
|
|
97
|
+
// const containerB = new MyContainerB({ name: 'ContainerB' });
|
|
98
|
+
|
|
99
|
+
// const concept = new A_Concept({
|
|
100
|
+
// name: 'TestConcept',
|
|
101
|
+
// containers: [
|
|
102
|
+
// containerA,
|
|
103
|
+
// containerB
|
|
104
|
+
// ]
|
|
105
|
+
// });
|
|
106
|
+
|
|
107
|
+
// await concept.load();
|
|
108
|
+
|
|
109
|
+
// expect(containerA.scope.resolve(MyContainerA)).toBeInstanceOf(MyContainerA);
|
|
110
|
+
// expect(containerB.scope.resolve(MyContainerB)).toBeInstanceOf(MyContainerB);
|
|
111
|
+
|
|
112
|
+
// expect(containerA._test).toBe(1);
|
|
113
|
+
// expect(containerB._test).toBe(1);
|
|
114
|
+
|
|
115
|
+
// })
|
|
116
|
+
// it('Should allow to define an async abstraction extension', async () => {
|
|
117
|
+
// A_Context.reset();
|
|
118
|
+
|
|
119
|
+
// class MyContainerA extends A_Container {
|
|
120
|
+
// _test: number = 0
|
|
121
|
+
|
|
122
|
+
// @A_Concept.Load()
|
|
123
|
+
// async myMethod() {
|
|
124
|
+
// this._test = 5;
|
|
125
|
+
// }
|
|
126
|
+
// }
|
|
127
|
+
// class MyContainerB extends A_Container {
|
|
128
|
+
// _test: number = 0
|
|
129
|
+
|
|
130
|
+
// @A_Concept.Load()
|
|
131
|
+
// myMethod() {
|
|
132
|
+
// this._test++;
|
|
133
|
+
// }
|
|
134
|
+
// }
|
|
13
135
|
|
|
14
|
-
@A_Concept.Load()
|
|
15
|
-
myMethod() {
|
|
16
|
-
this._test++;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('It should be possible to extend abstraction on A-Container level', async () => {
|
|
22
|
-
class MyContainer extends A_Container {
|
|
23
|
-
private _test: number = 0
|
|
24
|
-
|
|
25
|
-
@A_Concept.Load()
|
|
26
|
-
myMethod() {
|
|
27
|
-
this._test++;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
it('It should be possible to proceed Concept Abstraction', async () => {
|
|
34
|
-
class MyComponent extends A_Component {
|
|
35
|
-
_test2: number = 0
|
|
36
|
-
|
|
37
|
-
@A_Concept.Load()
|
|
38
|
-
myMethod() {
|
|
39
|
-
this._test2++;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
class MyContainer extends A_Container {
|
|
44
|
-
_test: number = 0
|
|
45
|
-
|
|
46
|
-
@A_Concept.Load()
|
|
47
|
-
myMethod() {
|
|
48
|
-
this._test++;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const myContainer = new MyContainer({
|
|
53
|
-
name: 'MyContainer',
|
|
54
|
-
components: [MyComponent]
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const testConcept = new A_Concept({
|
|
58
|
-
name: 'TestConcept',
|
|
59
|
-
containers: [myContainer]
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
await testConcept.load();
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const resolvedComponent = myContainer.scope.resolve(MyComponent);
|
|
66
|
-
|
|
67
|
-
expect(resolvedComponent).toBeInstanceOf(MyComponent);
|
|
68
|
-
expect(myContainer._test).toBe(1);
|
|
69
|
-
expect(resolvedComponent._test2).toBe(1);
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
it('Should allow to extend abstraction with multiple containers', async () => {
|
|
73
|
-
A_Context.reset();
|
|
74
|
-
|
|
75
|
-
class MyContainerA extends A_Container {
|
|
76
|
-
_test: number = 0
|
|
77
|
-
|
|
78
|
-
@A_Concept.Load()
|
|
79
|
-
myMethod() {
|
|
80
|
-
this._test++;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
class MyContainerB extends A_Container {
|
|
84
|
-
_test: number = 0
|
|
85
|
-
|
|
86
|
-
@A_Concept.Load()
|
|
87
|
-
myMethod() {
|
|
88
|
-
this._test++;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const containerA = new MyContainerA({ name: 'ContainerA' });
|
|
93
|
-
const containerB = new MyContainerB({ name: 'ContainerB' });
|
|
94
|
-
|
|
95
|
-
const concept = new A_Concept({
|
|
96
|
-
name: 'TestConcept',
|
|
97
|
-
containers: [
|
|
98
|
-
containerA,
|
|
99
|
-
containerB
|
|
100
|
-
]
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
await concept.load();
|
|
104
|
-
|
|
105
|
-
expect(containerA.scope.resolve(MyContainerA)).toBeInstanceOf(MyContainerA);
|
|
106
|
-
expect(containerB.scope.resolve(MyContainerB)).toBeInstanceOf(MyContainerB);
|
|
107
|
-
|
|
108
|
-
expect(containerA._test).toBe(1);
|
|
109
|
-
expect(containerB._test).toBe(1);
|
|
110
|
-
|
|
111
|
-
})
|
|
112
|
-
it('Should allow to define an async abstraction extension', async () => {
|
|
113
|
-
A_Context.reset();
|
|
114
|
-
|
|
115
|
-
class MyContainerA extends A_Container {
|
|
116
|
-
_test: number = 0
|
|
117
|
-
|
|
118
|
-
@A_Concept.Load()
|
|
119
|
-
async myMethod() {
|
|
120
|
-
this._test = 5;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
class MyContainerB extends A_Container {
|
|
124
|
-
_test: number = 0
|
|
125
|
-
|
|
126
|
-
@A_Concept.Load()
|
|
127
|
-
myMethod() {
|
|
128
|
-
this._test++;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
136
|
|
|
137
|
+
// const containerA = new MyContainerA({ name: 'ContainerA' });
|
|
138
|
+
// const containerB = new MyContainerB({ name: 'ContainerB' });
|
|
139
|
+
|
|
140
|
+
// const concept = new A_Concept({
|
|
141
|
+
// name: 'TestConcept',
|
|
142
|
+
// containers: [
|
|
143
|
+
// containerA,
|
|
144
|
+
// containerB
|
|
145
|
+
// ]
|
|
146
|
+
// });
|
|
147
|
+
|
|
148
|
+
// await concept.load();
|
|
149
|
+
|
|
150
|
+
// expect(containerA.scope.resolve(MyContainerA)).toBeInstanceOf(MyContainerA);
|
|
151
|
+
// expect(containerB.scope.resolve(MyContainerB)).toBeInstanceOf(MyContainerB);
|
|
152
|
+
|
|
153
|
+
// expect(containerA._test).toBe(5);
|
|
154
|
+
// expect(containerB._test).toBe(1);
|
|
155
|
+
// })
|
|
156
|
+
// it('Should execute abstraction in a proper order', async () => {
|
|
157
|
+
// A_Context.reset();
|
|
158
|
+
|
|
159
|
+
// const order: string[] = [];
|
|
160
|
+
|
|
161
|
+
// class MyContainerA extends A_Container {
|
|
162
|
+
|
|
163
|
+
// @A_Concept.Load()
|
|
164
|
+
// async step1() {
|
|
165
|
+
// order.push('step1');
|
|
166
|
+
// }
|
|
132
167
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
class MyContainerB extends A_Container {
|
|
170
|
-
|
|
171
|
-
@A_Concept.Load()
|
|
172
|
-
async step3() {
|
|
173
|
-
order.push('step3');
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
@A_Concept.Load()
|
|
177
|
-
async step4() {
|
|
178
|
-
order.push('step4');
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const containerA = new MyContainerA({ name: 'ContainerA' });
|
|
184
|
-
const containerB = new MyContainerB({ name: 'ContainerB' });
|
|
185
|
-
|
|
186
|
-
const concept = new A_Concept({
|
|
187
|
-
name: 'TestConcept',
|
|
188
|
-
containers: [
|
|
189
|
-
containerA,
|
|
190
|
-
containerB
|
|
191
|
-
]
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
await concept.load();
|
|
195
|
-
|
|
196
|
-
expect(order).toEqual(['step1', 'step2', 'step3', 'step4']);
|
|
197
|
-
})
|
|
168
|
+
// @A_Concept.Load()
|
|
169
|
+
// async step2() {
|
|
170
|
+
// order.push('step2');
|
|
171
|
+
// }
|
|
172
|
+
// }
|
|
173
|
+
// class MyContainerB extends A_Container {
|
|
174
|
+
|
|
175
|
+
// @A_Concept.Load()
|
|
176
|
+
// async step3() {
|
|
177
|
+
// order.push('step3');
|
|
178
|
+
// }
|
|
179
|
+
|
|
180
|
+
// @A_Concept.Load()
|
|
181
|
+
// async step4() {
|
|
182
|
+
// order.push('step4');
|
|
183
|
+
// }
|
|
184
|
+
// }
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
// const containerA = new MyContainerA({ name: 'ContainerA' });
|
|
188
|
+
// const containerB = new MyContainerB({ name: 'ContainerB' });
|
|
189
|
+
|
|
190
|
+
// const concept = new A_Concept({
|
|
191
|
+
// name: 'TestConcept',
|
|
192
|
+
// containers: [
|
|
193
|
+
// containerA,
|
|
194
|
+
// containerB
|
|
195
|
+
// ]
|
|
196
|
+
// });
|
|
197
|
+
|
|
198
|
+
// await concept.load();
|
|
199
|
+
|
|
200
|
+
// expect(order).toEqual(['step1', 'step2', 'step3', 'step4']);
|
|
201
|
+
// })
|
|
198
202
|
it('Should execute abstraction in order with dependencies', async () => {
|
|
199
203
|
A_Context.reset();
|
|
200
204
|
|
|
@@ -203,14 +207,20 @@ describe('A-Abstraction Tests', () => {
|
|
|
203
207
|
class MyContainerA extends A_Container {
|
|
204
208
|
|
|
205
209
|
@A_Concept.Load()
|
|
206
|
-
async step1(
|
|
210
|
+
async step1(
|
|
211
|
+
@A_Inject(A_Feature) feature: A_Feature,
|
|
212
|
+
) {
|
|
213
|
+
// console.log(`Executing step1 in stage: ${feature.stage?.name}`);
|
|
207
214
|
order.push('step1');
|
|
208
215
|
}
|
|
209
216
|
|
|
210
217
|
@A_Concept.Load({
|
|
211
218
|
after: ['MyComponentA.step3']
|
|
212
219
|
})
|
|
213
|
-
async step2(
|
|
220
|
+
async step2(
|
|
221
|
+
@A_Inject(A_Feature) feature: A_Feature,
|
|
222
|
+
) {
|
|
223
|
+
// console.log(`Executing step2 in stage: ${feature.stage?.name}`);
|
|
214
224
|
order.push('step2');
|
|
215
225
|
}
|
|
216
226
|
}
|
|
@@ -218,7 +228,10 @@ describe('A-Abstraction Tests', () => {
|
|
|
218
228
|
class MyComponentA extends A_Component {
|
|
219
229
|
|
|
220
230
|
@A_Concept.Load()
|
|
221
|
-
async step3(
|
|
231
|
+
async step3(
|
|
232
|
+
@A_Inject(A_Feature) feature: A_Feature,
|
|
233
|
+
) {
|
|
234
|
+
// console.log(`Executing step3 in stage: ${feature.stage?.name}`);
|
|
222
235
|
order.push('step3');
|
|
223
236
|
}
|
|
224
237
|
}
|
|
@@ -227,14 +240,20 @@ describe('A-Abstraction Tests', () => {
|
|
|
227
240
|
class MyContainerB extends A_Container {
|
|
228
241
|
|
|
229
242
|
@A_Concept.Load()
|
|
230
|
-
async step4(
|
|
243
|
+
async step4(
|
|
244
|
+
@A_Inject(A_Feature) feature: A_Feature,
|
|
245
|
+
) {
|
|
246
|
+
// console.log(`Executing step4 in stage: ${feature.stage?.name}`);
|
|
231
247
|
order.push('step4');
|
|
232
248
|
}
|
|
233
249
|
|
|
234
250
|
@A_Concept.Load({
|
|
235
251
|
before: ['MyContainerB.step4']
|
|
236
252
|
})
|
|
237
|
-
async step5(
|
|
253
|
+
async step5(
|
|
254
|
+
@A_Inject(A_Feature) feature: A_Feature,
|
|
255
|
+
) {
|
|
256
|
+
// console.log(`Executing step5 in stage: ${feature.stage?.name}`);
|
|
238
257
|
order.push('step5');
|
|
239
258
|
}
|
|
240
259
|
}
|
|
@@ -255,4 +274,69 @@ describe('A-Abstraction Tests', () => {
|
|
|
255
274
|
|
|
256
275
|
expect(order).toEqual(['step1', 'step3', 'step2', 'step5', 'step4']);
|
|
257
276
|
})
|
|
277
|
+
// it('Should inherit abstraction extensions', async () => {
|
|
278
|
+
// const executionOrder: string[] = [];
|
|
279
|
+
|
|
280
|
+
// // 1) create a base component with some abstraction
|
|
281
|
+
// class My_Component extends A_Component {
|
|
282
|
+
|
|
283
|
+
// @A_Concept.Load()
|
|
284
|
+
// async feature1() {
|
|
285
|
+
// executionOrder.push('stepOne');
|
|
286
|
+
// }
|
|
287
|
+
// }
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
// class My_Child_Component extends My_Component { }
|
|
291
|
+
|
|
292
|
+
// const concept = new A_Concept({
|
|
293
|
+
// name: 'TestConcept',
|
|
294
|
+
// containers: [
|
|
295
|
+
// new A_Container({
|
|
296
|
+
// name: 'TestContainer',
|
|
297
|
+
// components: [My_Child_Component],
|
|
298
|
+
// })
|
|
299
|
+
// ]
|
|
300
|
+
// });
|
|
301
|
+
|
|
302
|
+
// await concept.load();
|
|
303
|
+
|
|
304
|
+
// expect(executionOrder).toEqual(['stepOne']);
|
|
305
|
+
// });
|
|
306
|
+
// it('Should allow to override abstraction extensions', async () => {
|
|
307
|
+
// const executionOrder: string[] = [];
|
|
308
|
+
|
|
309
|
+
// // 1) create a base component with some abstraction
|
|
310
|
+
// class My_Component extends A_Component {
|
|
311
|
+
|
|
312
|
+
// @A_Concept.Load()
|
|
313
|
+
// async feature1() {
|
|
314
|
+
// executionOrder.push('stepOne');
|
|
315
|
+
// }
|
|
316
|
+
// }
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
// class My_Child_Component extends My_Component {
|
|
320
|
+
// @A_Concept.Load()
|
|
321
|
+
// async feature1() {
|
|
322
|
+
// // do nothing
|
|
323
|
+
// executionOrder.push('stepTwo');
|
|
324
|
+
|
|
325
|
+
// }
|
|
326
|
+
// }
|
|
327
|
+
|
|
328
|
+
// const concept = new A_Concept({
|
|
329
|
+
// name: 'TestConcept',
|
|
330
|
+
// containers: [
|
|
331
|
+
// new A_Container({
|
|
332
|
+
// name: 'TestContainer',
|
|
333
|
+
// components: [My_Child_Component],
|
|
334
|
+
// })
|
|
335
|
+
// ]
|
|
336
|
+
// });
|
|
337
|
+
|
|
338
|
+
// await concept.load();
|
|
339
|
+
|
|
340
|
+
// expect(executionOrder).toEqual(['stepTwo']);
|
|
341
|
+
// });
|
|
258
342
|
});
|
package/tests/A-Feature.test.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
|
|
|
6
6
|
import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
|
|
7
7
|
import { A_Caller } from '@adaas/a-concept/global/A-Caller/A_Caller.class';
|
|
8
8
|
import { A_Context } from '@adaas/a-concept/global/A-Context/A-Context.class';
|
|
9
|
+
import { A_TYPES__ComponentMetaKey } from '@adaas/a-concept/global/A-Component/A-Component.constants';
|
|
9
10
|
|
|
10
11
|
jest.retryTimes(0);
|
|
11
12
|
|
|
@@ -253,7 +254,7 @@ describe('A-Feature tests', () => {
|
|
|
253
254
|
|
|
254
255
|
@A_Feature.Define()
|
|
255
256
|
async feature2() {
|
|
256
|
-
|
|
257
|
+
await this.call('feature2');
|
|
257
258
|
}
|
|
258
259
|
|
|
259
260
|
@A_Feature.Extend({
|
|
@@ -281,4 +282,86 @@ describe('A-Feature tests', () => {
|
|
|
281
282
|
// 5) check the results
|
|
282
283
|
expect(executionOrder).toEqual(['stepOne', 'stepTwo']);
|
|
283
284
|
});
|
|
285
|
+
it('Should inherit feature definitions & extensions', async () => {
|
|
286
|
+
const executionOrder: string[] = [];
|
|
287
|
+
|
|
288
|
+
// 1) create a base component with some feature
|
|
289
|
+
class My_Component extends A_Component {
|
|
290
|
+
|
|
291
|
+
@A_Feature.Define({ invoke: false })
|
|
292
|
+
async feature1() {
|
|
293
|
+
executionOrder.push('stepOne');
|
|
294
|
+
|
|
295
|
+
await this.call('feature1');
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
@A_Feature.Extend({
|
|
299
|
+
name: 'feature1',
|
|
300
|
+
})
|
|
301
|
+
async feature1Extension(
|
|
302
|
+
@A_Inject(A_Scope) scope: A_Scope
|
|
303
|
+
) {
|
|
304
|
+
executionOrder.push('stepTwo');
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
class My_Child_Component extends My_Component { }
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
// 2) create a running scope
|
|
313
|
+
const scope = new A_Scope({ name: 'TestScope', components: [My_Child_Component] });
|
|
314
|
+
|
|
315
|
+
// 3) create an instance of the component from the scope
|
|
316
|
+
const myComponent = scope.resolve(My_Child_Component);
|
|
317
|
+
expect(myComponent).toBeInstanceOf(My_Child_Component);
|
|
318
|
+
|
|
319
|
+
await myComponent.feature1();
|
|
320
|
+
|
|
321
|
+
expect(executionOrder).toEqual(['stepOne', 'stepTwo']);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it('Should allow override feature extension', async () => {
|
|
325
|
+
const executionOrder: string[] = [];
|
|
326
|
+
|
|
327
|
+
// 1) create a base component with some feature
|
|
328
|
+
class My_Component extends A_Component {
|
|
329
|
+
|
|
330
|
+
@A_Feature.Define({ invoke: true })
|
|
331
|
+
async feature1() {
|
|
332
|
+
executionOrder.push('stepOne');
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
@A_Feature.Extend({
|
|
336
|
+
name: 'feature1',
|
|
337
|
+
})
|
|
338
|
+
async feature1Extension(
|
|
339
|
+
@A_Inject(A_Scope) scope: A_Scope
|
|
340
|
+
) {
|
|
341
|
+
executionOrder.push('stepTwo');
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
class My_Child_Component extends My_Component {
|
|
347
|
+
|
|
348
|
+
async feature1Extension(
|
|
349
|
+
@A_Inject(A_Scope) scope: A_Scope
|
|
350
|
+
) {
|
|
351
|
+
executionOrder.push('stepThree');
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
// 2) create a running scope
|
|
357
|
+
const scope = new A_Scope({ name: 'TestScope', components: [My_Child_Component] });
|
|
358
|
+
|
|
359
|
+
// 3) create an instance of the component from the scope
|
|
360
|
+
const myComponent = scope.resolve(My_Child_Component);
|
|
361
|
+
expect(myComponent).toBeInstanceOf(My_Child_Component);
|
|
362
|
+
|
|
363
|
+
await myComponent.feature1();
|
|
364
|
+
|
|
365
|
+
expect(executionOrder).toEqual(['stepOne', 'stepThree']);
|
|
366
|
+
});
|
|
284
367
|
});
|