@hg-ts/tests 0.5.19 → 0.5.21
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/decorators/expect-error.decorator.d.ts +1 -1
- package/dist/decorators/expect-error.decorator.d.ts.map +1 -1
- package/dist/decorators/expect-error.decorator.js +11 -3
- package/dist/decorators/expect-error.decorator.js.map +1 -1
- package/package.json +4 -4
- package/src/decorators/expect-error.decorator.ts +12 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function ExpectException(error?: AnyCLass<any, any[]
|
|
1
|
+
export declare function ExpectException(error?: AnyCLass<any, any[]>, name?: string, message?: string): MethodDecorator;
|
|
2
2
|
//# sourceMappingURL=expect-error.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expect-error.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/expect-error.decorator.ts"],"names":[],"mappings":"AAGA,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"expect-error.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/expect-error.decorator.ts"],"names":[],"mappings":"AAGA,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,eAAe,CAyB9G"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { expect } from 'vitest';
|
|
2
2
|
import { createTestDecorator } from './decorate-test.js';
|
|
3
|
-
export function ExpectException(error) {
|
|
3
|
+
export function ExpectException(error, name, message) {
|
|
4
4
|
return createTestDecorator(async (method) => {
|
|
5
5
|
let isThrowError = false;
|
|
6
6
|
try {
|
|
@@ -9,11 +9,19 @@ export function ExpectException(error) {
|
|
|
9
9
|
catch (err) {
|
|
10
10
|
isThrowError = true;
|
|
11
11
|
if (error) {
|
|
12
|
-
expect(err, '
|
|
12
|
+
expect(err, 'Exception type check').toBeInstanceOf(error);
|
|
13
|
+
}
|
|
14
|
+
if (name) {
|
|
15
|
+
expect(err, 'Exception must be instance of Error to check name').toBeInstanceOf(Error);
|
|
16
|
+
expect(err.name, 'Exception name check').toBe(name);
|
|
17
|
+
}
|
|
18
|
+
if (message) {
|
|
19
|
+
expect(err, 'Exception must be instance of Error to check message').toBeInstanceOf(Error);
|
|
20
|
+
expect(err.message, 'Exception message check').toBe(message);
|
|
13
21
|
}
|
|
14
22
|
}
|
|
15
23
|
finally {
|
|
16
|
-
expect(isThrowError, '
|
|
24
|
+
expect(isThrowError, 'Exception caught check').toBeTruthy();
|
|
17
25
|
}
|
|
18
26
|
});
|
|
19
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expect-error.decorator.js","sourceRoot":"","sources":["../../src/decorators/expect-error.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,UAAU,eAAe,CAAC,KAA4B;
|
|
1
|
+
{"version":3,"file":"expect-error.decorator.js","sourceRoot":"","sources":["../../src/decorators/expect-error.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,UAAU,eAAe,CAAC,KAA4B,EAAE,IAAa,EAAE,OAAgB;IAC5F,OAAO,mBAAmB,CAAC,KAAK,EAAC,MAA2B,EAAE,EAAE;QAC/D,IAAI,YAAY,GAAG,KAAK,CAAC;QAEzB,IAAI,CAAC;YACJ,MAAM,MAAM,EAAE,CAAC;QAChB,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACvB,YAAY,GAAG,IAAI,CAAC;YAEpB,IAAI,KAAK,EAAE,CAAC;gBACX,MAAM,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC3D,CAAC;YAED,IAAI,IAAI,EAAE,CAAC;gBACV,MAAM,CAAC,GAAG,EAAE,mDAAmD,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;gBACvF,MAAM,CAAE,GAAa,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAChE,CAAC;YACD,IAAI,OAAO,EAAE,CAAC;gBACb,MAAM,CAAC,GAAG,EAAE,sDAAsD,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;gBAC1F,MAAM,CAAE,GAAa,CAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACzE,CAAC;QACF,CAAC;gBAAS,CAAC;YACV,MAAM,CAAC,YAAY,EAAE,wBAAwB,CAAC,CAAC,UAAU,EAAE,CAAC;QAC7D,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hg-ts/tests",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.21",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"unplugin-swc": "1.5.9"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@hg-ts-config/typescript": "0.5.
|
|
28
|
-
"@hg-ts/linter": "0.5.
|
|
29
|
-
"@hg-ts/types": "0.5.
|
|
27
|
+
"@hg-ts-config/typescript": "0.5.21",
|
|
28
|
+
"@hg-ts/linter": "0.5.21",
|
|
29
|
+
"@hg-ts/types": "0.5.21",
|
|
30
30
|
"@types/node": "22.19.1",
|
|
31
31
|
"@vitest/coverage-v8": "4.0.14",
|
|
32
32
|
"eslint": "9.18.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { expect } from 'vitest';
|
|
2
2
|
import { createTestDecorator } from './decorate-test.js';
|
|
3
3
|
|
|
4
|
-
export function ExpectException(error?: AnyCLass<any, any[]
|
|
4
|
+
export function ExpectException(error?: AnyCLass<any, any[]>, name?: string, message?: string): MethodDecorator {
|
|
5
5
|
return createTestDecorator(async(method: () => Promise<void>) => {
|
|
6
6
|
let isThrowError = false;
|
|
7
7
|
|
|
@@ -11,10 +11,19 @@ export function ExpectException(error?: AnyCLass<any, any[]>): MethodDecorator {
|
|
|
11
11
|
isThrowError = true;
|
|
12
12
|
|
|
13
13
|
if (error) {
|
|
14
|
-
expect(err, '
|
|
14
|
+
expect(err, 'Exception type check').toBeInstanceOf(error);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (name) {
|
|
18
|
+
expect(err, 'Exception must be instance of Error to check name').toBeInstanceOf(Error);
|
|
19
|
+
expect((err as Error).name, 'Exception name check').toBe(name);
|
|
20
|
+
}
|
|
21
|
+
if (message) {
|
|
22
|
+
expect(err, 'Exception must be instance of Error to check message').toBeInstanceOf(Error);
|
|
23
|
+
expect((err as Error).message, 'Exception message check').toBe(message);
|
|
15
24
|
}
|
|
16
25
|
} finally {
|
|
17
|
-
expect(isThrowError, '
|
|
26
|
+
expect(isThrowError, 'Exception caught check').toBeTruthy();
|
|
18
27
|
}
|
|
19
28
|
});
|
|
20
29
|
}
|