@adaas/a-concept 0.3.1 → 0.3.3

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.
@@ -132,7 +132,7 @@ describe('A-Meta tests', () => {
132
132
  expect(metaE.get(A_TYPES__ComponentMetaKey.EXTENSIONS)?.get('.*\\.testFeature$')?.map(e => e.handler)).toContain('test3');
133
133
  expect(metaE.get(A_TYPES__ComponentMetaKey.EXTENSIONS)?.get('.*\\.testFeature$')?.map(e => e.handler)).not.toContain('test2');
134
134
  })
135
- it('Should allow to inherit meta properly', async () => {
135
+ it('Should allow to define a custom meta', async () => {
136
136
 
137
137
  class InjectableComponent extends A_Component { }
138
138
 
@@ -170,6 +170,49 @@ describe('A-Meta tests', () => {
170
170
  expect(meta).toBeInstanceOf(CustomComponentMeta);
171
171
  expect(meta).toHaveProperty('customField');
172
172
 
173
+ expect(meta.get(A_TYPES__ComponentMetaKey.EXTENSIONS)?.size()).toBe(1);
174
+ expect(meta.get(A_TYPES__ComponentMetaKey.EXTENSIONS)?.has('.*\\.testFeature$')).toBe(true);
175
+ })
176
+ it('Should propagate a custom me', async () => {
177
+
178
+ class InjectableComponent extends A_Component { }
179
+
180
+ class CustomComponentMeta extends A_ComponentMeta<{ customField: string } & A_TYPES__ComponentMeta> {
181
+
182
+ get customField(): string | undefined {
183
+ return this.get('customField');
184
+ }
185
+ }
186
+
187
+ @A_Meta.Define(CustomComponentMeta)
188
+ class CustomComponent extends A_Component {
189
+
190
+ static Test() {
191
+
192
+ }
193
+
194
+ constructor(
195
+ @A_Inject(InjectableComponent) public injectableComponent: InjectableComponent
196
+ ) {
197
+ super();
198
+ }
199
+
200
+ @A_Feature.Extend({
201
+ name: 'testFeature'
202
+ })
203
+ async feature() {
204
+
205
+ }
206
+ }
207
+
208
+ class SubCustomComponent extends CustomComponent {}
209
+
210
+
211
+ const meta = A_Context.meta<CustomComponentMeta>(SubCustomComponent);
212
+
213
+ expect(meta).toBeInstanceOf(CustomComponentMeta);
214
+ expect(meta).toHaveProperty('customField');
215
+
173
216
  expect(meta.get(A_TYPES__ComponentMetaKey.EXTENSIONS)?.size()).toBe(1);
174
217
  expect(meta.get(A_TYPES__ComponentMetaKey.EXTENSIONS)?.has('.*\\.testFeature$')).toBe(true);
175
218
  })
@@ -106,7 +106,24 @@ describe('A-Scope tests', () => {
106
106
  const resolved = childScope.resolve(A_Component);
107
107
  expect(resolved).toBe(component);
108
108
  });
109
+ it('should resolve component constructor registered in scope', async () => {
110
+ class testComponent extends A_Component { }
109
111
 
112
+ const parentScope = new A_Scope({ name: 'ParentScope', components: [testComponent] });
113
+
114
+ const resolved = parentScope.resolveConstructor(testComponent);
115
+ expect(resolved).toBe(testComponent);
116
+ });
117
+ it('should resolve inherited component constructor in scope', async () => {
118
+ class testComponent extends A_Component { }
119
+ class inheritedComponent extends testComponent { }
120
+
121
+ const parentScope = new A_Scope({ name: 'ParentScope', components: [inheritedComponent] });
122
+
123
+ const resolved = parentScope.resolveConstructor(testComponent);
124
+
125
+ expect(resolved).toBe(inheritedComponent);
126
+ });
110
127
  it('Should resolve only one entity if no query is provided', async () => {
111
128
  class MyEntity extends A_Entity<{ bar: string }> {
112
129
  public bar!: string;