@cobol-ts/test_utils 0.0.59 → 1.0.0

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const capture_error_log_1 = require("./capture.error.log");
4
+ const channels = [
5
+ { channel: 'error', capture: capture_error_log_1.captureConsoleError, captureAsync: capture_error_log_1.captureConsoleErrorAsync, field: 'errors' },
6
+ { channel: 'log', capture: capture_error_log_1.captureConsoleLog, captureAsync: capture_error_log_1.captureConsoleLogAsync, field: 'logs' }
7
+ ];
8
+ describe.each(channels)('console $channel capture', ({ channel, capture, captureAsync, field }) => {
9
+ test('preserves message arguments and result, and restores the original console method', () => {
10
+ const original = console[channel], detail = { customer: 17 };
11
+ const result = capture(() => {
12
+ console[channel]('first', detail);
13
+ console[channel]('second');
14
+ return 42;
15
+ });
16
+ expect(result).toEqual({ result: 42, [field]: [['first', detail], ['second']] });
17
+ expect(console[channel]).toBe(original);
18
+ });
19
+ test('restores the console method even when the callback throws', () => {
20
+ const original = console[channel], failure = new Error('callback failed');
21
+ expect(() => capture(() => { throw failure; })).toThrow(failure);
22
+ expect(console[channel]).toBe(original);
23
+ });
24
+ test('captures messages after an await and restores the console method', async () => {
25
+ const original = console[channel];
26
+ const result = await captureAsync(async () => {
27
+ console[channel]('before');
28
+ await Promise.resolve();
29
+ console[channel]('after', 17);
30
+ return 'done';
31
+ });
32
+ expect(result).toEqual({ result: 'done', [field]: [['before'], ['after', 17]] });
33
+ expect(console[channel]).toBe(original);
34
+ });
35
+ test('restores the console method on asynchronous rejection', async () => {
36
+ const original = console[channel], failure = new Error('callback rejected');
37
+ await expect(captureAsync(async () => { await Promise.resolve(); throw failure; })).rejects.toThrow(failure);
38
+ expect(console[channel]).toBe(original);
39
+ });
40
+ });
41
+ //# sourceMappingURL=capture.error.log.spec.js.map
@@ -0,0 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EAAE,GAAE,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,OAAO,CAAA,CAAA,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QACzG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC3C,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cobol-ts/test_utils",
3
3
  "description": "test utilities for the @cobol-ts project",
4
- "version": "0.0.59",
4
+ "version": "1.0.0",
5
5
  "main": "dist/index",
6
6
  "types": "dist/index",
7
7
  "browserslist": {
@@ -16,13 +16,14 @@
16
16
  "not op_mini all"
17
17
  ]
18
18
  },
19
+ "dependencies": {},
19
20
  "devDependencies": {
21
+ "typescript": "^5.2.2",
20
22
  "@testing-library/jest-dom": "^6.1.4",
21
23
  "@types/jest": "^29.0.0",
22
24
  "@types/node": "^14.0.0",
23
25
  "jest": "^29.0.0",
24
- "ts-jest": "^29.0.0",
25
- "typescript": "^5.2.2"
26
+ "ts-jest": "^29.0.0"
26
27
  },
27
28
  "eslintConfig": {
28
29
  "extends": [