@hg-ts/tests 0.5.18 → 0.5.20

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.
@@ -1,2 +1,2 @@
1
- export declare function ExpectException(error?: AnyCLass<any, any[]>): MethodDecorator;
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,CAgB7E"}
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,CAuB9G"}
@@ -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 {
@@ -8,12 +8,18 @@ export function ExpectException(error) {
8
8
  }
9
9
  catch (err) {
10
10
  isThrowError = true;
11
- if (error) {
12
- expect(err).toBeInstanceOf(error);
11
+ expect(err, 'Exception type check').toBeInstanceOf(error);
12
+ if (err instanceof Error) {
13
+ if (name) {
14
+ expect(name, 'Exception name check').toBe(name);
15
+ }
16
+ if (message) {
17
+ expect(message, 'Exception message check').toBe(message);
18
+ }
13
19
  }
14
20
  }
15
21
  finally {
16
- expect(isThrowError).toBeTruthy();
22
+ expect(isThrowError, 'Exception caught check').toBeTruthy();
17
23
  }
18
24
  });
19
25
  }
@@ -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;IAC3D,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,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACnC,CAAC;QACF,CAAC;gBAAS,CAAC;YACV,MAAM,CAAC,YAAY,CAAC,CAAC,UAAU,EAAE,CAAC;QACnC,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC"}
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,MAAM,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAE1D,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;gBAC1B,IAAI,IAAI,EAAE,CAAC;oBACV,MAAM,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACjD,CAAC;gBACD,IAAI,OAAO,EAAE,CAAC;oBACb,MAAM,CAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAC1D,CAAC;YACF,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.18",
3
+ "version": "0.5.20",
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.18",
28
- "@hg-ts/linter": "0.5.18",
29
- "@hg-ts/types": "0.5.18",
27
+ "@hg-ts-config/typescript": "0.5.20",
28
+ "@hg-ts/linter": "0.5.20",
29
+ "@hg-ts/types": "0.5.20",
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[]>): MethodDecorator {
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
 
@@ -10,11 +10,18 @@ export function ExpectException(error?: AnyCLass<any, any[]>): MethodDecorator {
10
10
  } catch (err: unknown) {
11
11
  isThrowError = true;
12
12
 
13
- if (error) {
14
- expect(err).toBeInstanceOf(error);
13
+ expect(err, 'Exception type check').toBeInstanceOf(error);
14
+
15
+ if (err instanceof Error) {
16
+ if (name) {
17
+ expect(name, 'Exception name check').toBe(name);
18
+ }
19
+ if (message) {
20
+ expect(message, 'Exception message check').toBe(message);
21
+ }
15
22
  }
16
23
  } finally {
17
- expect(isThrowError).toBeTruthy();
24
+ expect(isThrowError, 'Exception caught check').toBeTruthy();
18
25
  }
19
26
  });
20
27
  }