@adaas/a-concept 0.1.54 → 0.1.55
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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/global/A-Scope/A-Scope.class.ts +5 -6
- package/tests/A-Scope.test.ts +18 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaas/a-concept",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.55",
|
|
4
4
|
"description": "A-Concept is a framework to build new Applications within or outside the ADAAS ecosystem. This framework is designed to be modular structure regardless environment and program goal.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -703,10 +703,9 @@ export class A_Scope<
|
|
|
703
703
|
|
|
704
704
|
case A_TypeGuards.isEntityConstructor(param1): {
|
|
705
705
|
// 3) Check entities
|
|
706
|
-
this.
|
|
707
|
-
if (A_CommonHelper.isInheritedFrom(
|
|
708
|
-
|
|
709
|
-
if (instance) results.push(instance as T);
|
|
706
|
+
this.entities.forEach(entity => {
|
|
707
|
+
if (A_CommonHelper.isInheritedFrom(entity.constructor, param1)) {
|
|
708
|
+
results.push(entity as T);
|
|
710
709
|
}
|
|
711
710
|
});
|
|
712
711
|
break;
|
|
@@ -740,13 +739,13 @@ export class A_Scope<
|
|
|
740
739
|
|
|
741
740
|
|
|
742
741
|
const parentScope = this._parent;
|
|
743
|
-
|
|
742
|
+
|
|
744
743
|
while (parentScope && parentScope.has(param1 as any)) {
|
|
745
744
|
const parentResults = parentScope.resolveAll<T>(param1 as any);
|
|
746
745
|
results.push(...parentResults);
|
|
747
746
|
break;
|
|
748
747
|
}
|
|
749
|
-
|
|
748
|
+
|
|
750
749
|
|
|
751
750
|
return results;
|
|
752
751
|
}
|
package/tests/A-Scope.test.ts
CHANGED
|
@@ -433,5 +433,23 @@ describe('A-Scope tests', () => {
|
|
|
433
433
|
// the first element should be instance of ComponentC as it is registered in child scope
|
|
434
434
|
expect(resolvedComponents[0] instanceof ComponentC).toBe(true);
|
|
435
435
|
});
|
|
436
|
+
it('Should resolve all entities registered in the scope', async () => {
|
|
436
437
|
|
|
438
|
+
class MyEntity extends A_Entity { }
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
const scope = new A_Scope({ name: 'TestScope' });
|
|
442
|
+
|
|
443
|
+
scope.register(new MyEntity());
|
|
444
|
+
scope.register(new MyEntity());
|
|
445
|
+
scope.register(new MyEntity());
|
|
446
|
+
|
|
447
|
+
const resolvedEntities = scope.resolveAll<MyEntity>(MyEntity);
|
|
448
|
+
|
|
449
|
+
expect(resolvedEntities.length).toBe(3);
|
|
450
|
+
resolvedEntities.forEach(entity => {
|
|
451
|
+
expect(entity).toBeInstanceOf(MyEntity);
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
});
|
|
437
455
|
});
|