@adaas/a-concept 0.1.8 → 0.1.10
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/src/global/A-Error/A_Error.class.d.ts +22 -12
- package/dist/src/global/A-Error/A_Error.class.js +71 -42
- package/dist/src/global/A-Error/A_Error.class.js.map +1 -1
- package/dist/src/global/A-Error/A_Error.types.d.ts +6 -2
- package/dist/src/global/A-Feature/A-Feature.class.js +1 -1
- package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
- package/dist/src/global/A-Scope/A-Scope.class.js +22 -12
- package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
- package/dist/src/global/A-Scope/A-Scope.error.d.ts +1 -0
- package/dist/src/global/A-Scope/A-Scope.error.js +1 -0
- package/dist/src/global/A-Scope/A-Scope.error.js.map +1 -1
- package/dist/src/helpers/A_TypeGuards.helper.js +1 -1
- package/dist/src/helpers/A_TypeGuards.helper.js.map +1 -1
- package/package.json +2 -2
- package/src/global/A-Error/A_Error.class.ts +102 -46
- package/src/global/A-Error/A_Error.types.ts +6 -3
- package/src/global/A-Feature/A-Feature.class.ts +1 -1
- package/src/global/A-Scope/A-Scope.class.ts +43 -15
- package/src/global/A-Scope/A-Scope.error.ts +2 -0
- package/src/helpers/A_TypeGuards.helper.ts +1 -1
- package/tests/A-Abstraction.test.ts +42 -1
- package/tests/A-Component.test.ts +25 -1
- package/tests/A-Error.test.ts +22 -9
- package/tests/A-Scope.test.ts +21 -0
package/tests/A-Error.test.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { A_CONSTANTS__DEFAULT_ENV_VARIABLES } from "@adaas/a-concept/constants/e
|
|
|
2
2
|
import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
3
3
|
import { A_Error } from "@adaas/a-concept/global/A-Error/A_Error.class";
|
|
4
4
|
import { A_CONSTANTS__ERROR_CODES, A_CONSTANTS__ERROR_DESCRIPTION } from "@adaas/a-concept/global/A-Error/A_Error.constants";
|
|
5
|
+
import { A_FormatterHelper } from "@adaas/a-concept/helpers/A_Formatter.helper";
|
|
5
6
|
|
|
6
7
|
jest.retryTimes(0);
|
|
7
8
|
|
|
@@ -13,7 +14,8 @@ describe('A-Error Tests', () => {
|
|
|
13
14
|
|
|
14
15
|
expect(error).toBeDefined();
|
|
15
16
|
expect(error.message).toBe('Test error');
|
|
16
|
-
expect(error.
|
|
17
|
+
expect(error.title).toBe(A_CONSTANTS__ERROR_CODES.UNEXPECTED_ERROR);
|
|
18
|
+
expect(error.code).toBe(A_FormatterHelper.toKebabCase(A_CONSTANTS__ERROR_CODES.UNEXPECTED_ERROR));
|
|
17
19
|
expect(error.type).toBe('a-error');
|
|
18
20
|
});
|
|
19
21
|
|
|
@@ -24,7 +26,8 @@ describe('A-Error Tests', () => {
|
|
|
24
26
|
|
|
25
27
|
expect(error).toBeDefined();
|
|
26
28
|
expect(error.message).toBe('Original error');
|
|
27
|
-
expect(error.
|
|
29
|
+
expect(error.title).toBe(A_CONSTANTS__ERROR_CODES.UNEXPECTED_ERROR);
|
|
30
|
+
expect(error.code).toBe(A_FormatterHelper.toKebabCase(A_CONSTANTS__ERROR_CODES.UNEXPECTED_ERROR));
|
|
28
31
|
expect(error.type).toBe('a-error');
|
|
29
32
|
expect(error.originalError).toBe(originalError);
|
|
30
33
|
});
|
|
@@ -36,7 +39,8 @@ describe('A-Error Tests', () => {
|
|
|
36
39
|
|
|
37
40
|
expect(error).toBeDefined();
|
|
38
41
|
expect(error).toBe(originalError);
|
|
39
|
-
expect(error.
|
|
42
|
+
expect(error.title).toBe('Original A_Error');
|
|
43
|
+
expect(error.message).toBe('[Original A_Error]: This is the original error');
|
|
40
44
|
expect(error.code).toBe('original-a-error');
|
|
41
45
|
expect(error.type).toBe('a-error');
|
|
42
46
|
expect(error.description).toBe('This is the original error');
|
|
@@ -48,13 +52,14 @@ describe('A-Error Tests', () => {
|
|
|
48
52
|
const originalError = new A_Error('Original A_Error', 'This is the original error');
|
|
49
53
|
const error = new A_Error({
|
|
50
54
|
code: 'test-code',
|
|
51
|
-
|
|
55
|
+
title: 'Custom error message',
|
|
52
56
|
description: 'This is a custom error description',
|
|
53
57
|
originalError
|
|
54
58
|
});
|
|
55
59
|
|
|
56
60
|
expect(error).toBeDefined();
|
|
57
|
-
expect(error.
|
|
61
|
+
expect(error.title).toBe('Custom error message');
|
|
62
|
+
expect(error.message).toBe('[Custom error message]: This is a custom error description');
|
|
58
63
|
expect(error.code).toBe('test-code');
|
|
59
64
|
expect(error.type).toBe('a-error');
|
|
60
65
|
expect(error.description).toBe('This is a custom error description');
|
|
@@ -66,11 +71,12 @@ describe('A-Error Tests', () => {
|
|
|
66
71
|
const originalError = new A_Error('Original A_Error', 'This is the original error');
|
|
67
72
|
|
|
68
73
|
const error = new A_Error({
|
|
69
|
-
|
|
74
|
+
title: 'Custom error message',
|
|
70
75
|
originalError: originalError
|
|
71
76
|
});
|
|
72
77
|
|
|
73
78
|
expect(error).toBeDefined();
|
|
79
|
+
expect(error.title).toBe('Custom error message');
|
|
74
80
|
expect(error.message).toBe('Custom error message');
|
|
75
81
|
expect(error.code).toBe('custom-error-message');
|
|
76
82
|
expect(error.type).toBe('a-error');
|
|
@@ -84,20 +90,26 @@ describe('A-Error Tests', () => {
|
|
|
84
90
|
const error = new MyError('Test inherited error');
|
|
85
91
|
|
|
86
92
|
expect(error).toBeDefined();
|
|
93
|
+
expect(error.title).toBe(A_CONSTANTS__ERROR_CODES.UNEXPECTED_ERROR);
|
|
94
|
+
expect(error.code).toBe(A_FormatterHelper.toKebabCase(A_CONSTANTS__ERROR_CODES.UNEXPECTED_ERROR));
|
|
87
95
|
expect(error.message).toBe('Test inherited error');
|
|
88
|
-
expect(error.code).toBe('test-inherited-error');
|
|
89
96
|
expect(error.type).toBe('my-error');
|
|
90
97
|
});
|
|
91
98
|
|
|
92
99
|
it('It should be possible to serialize an A_Error instance', async () => {
|
|
93
100
|
|
|
94
101
|
const originalError = new A_Error('Original A_Error', 'This is the original error');
|
|
102
|
+
|
|
103
|
+
expect(originalError.title).toBe('Original A_Error');
|
|
104
|
+
|
|
105
|
+
|
|
95
106
|
const error = new A_Error(originalError);
|
|
96
107
|
|
|
97
108
|
const serialized = error.toJSON();
|
|
98
109
|
|
|
99
110
|
expect(serialized).toBeDefined();
|
|
100
|
-
expect(serialized.
|
|
111
|
+
expect(serialized.title).toBe('Original A_Error');
|
|
112
|
+
expect(serialized.message).toBe('[Original A_Error]: This is the original error');
|
|
101
113
|
expect(serialized.code).toBe('original-a-error');
|
|
102
114
|
expect(serialized.type).toBe('a-error');
|
|
103
115
|
expect(serialized.scope).toBe('root');
|
|
@@ -115,7 +127,8 @@ describe('A-Error Tests', () => {
|
|
|
115
127
|
|
|
116
128
|
expect(error).toBeDefined();
|
|
117
129
|
expect(error.message).toBe('Test error in custom concept and scope');
|
|
118
|
-
expect(error.
|
|
130
|
+
expect(error.title).toBe(A_CONSTANTS__ERROR_CODES.UNEXPECTED_ERROR);
|
|
131
|
+
expect(error.code).toBe(A_FormatterHelper.toKebabCase(A_CONSTANTS__ERROR_CODES.UNEXPECTED_ERROR));
|
|
119
132
|
expect(error.type).toBe('a-error');
|
|
120
133
|
expect(error.aseid.concept).toBe('my-project');
|
|
121
134
|
expect(error.aseid.scope).toBe('my-scope');
|
package/tests/A-Scope.test.ts
CHANGED
|
@@ -286,7 +286,28 @@ describe('A-Scope tests', () => {
|
|
|
286
286
|
expect(resolvedFragmentB).toBeInstanceOf(fragmentB);
|
|
287
287
|
|
|
288
288
|
expect(scope.resolve(customEntity)).toBeInstanceOf(customEntity);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it('Should resolve inherited components', async () => {
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
class componentA extends A_Component { }
|
|
295
|
+
class componentB extends componentA { }
|
|
296
|
+
|
|
297
|
+
class customContainer extends A_Container { }
|
|
289
298
|
|
|
299
|
+
const container = new customContainer({
|
|
300
|
+
name: 'CustomContainer',
|
|
301
|
+
components: [componentB],
|
|
302
|
+
})
|
|
303
|
+
expect(container.scope.has(componentB)).toBe(true);
|
|
304
|
+
expect(container.scope.has(componentA)).toBe(true);
|
|
305
|
+
|
|
306
|
+
expect(container).toBeInstanceOf(customContainer);
|
|
307
|
+
const scope = container.scope;
|
|
308
|
+
|
|
309
|
+
expect(scope.resolve(componentA)).toBeInstanceOf(componentB);
|
|
310
|
+
expect(scope.resolve(componentB)).toBeInstanceOf(componentB);
|
|
290
311
|
|
|
291
312
|
});
|
|
292
313
|
});
|