@zudojs/testing 0.0.1
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/README.md +35 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/assertions/errorAssertions.core.d.ts +37 -0
- package/dist/assertions/errorAssertions.core.d.ts.map +1 -0
- package/dist/assertions/errorAssertions.core.js +82 -0
- package/dist/assertions/errorAssertions.core.js.map +1 -0
- package/dist/assertions/eventAssertions.core.d.ts +44 -0
- package/dist/assertions/eventAssertions.core.d.ts.map +1 -0
- package/dist/assertions/eventAssertions.core.js +63 -0
- package/dist/assertions/eventAssertions.core.js.map +1 -0
- package/dist/assertions/httpAssertions.core.d.ts +54 -0
- package/dist/assertions/httpAssertions.core.d.ts.map +1 -0
- package/dist/assertions/httpAssertions.core.js +80 -0
- package/dist/assertions/httpAssertions.core.js.map +1 -0
- package/dist/assertions/index.d.ts +9 -0
- package/dist/assertions/index.d.ts.map +1 -0
- package/dist/assertions/index.js +9 -0
- package/dist/assertions/index.js.map +1 -0
- package/dist/cleanupManager/cleanupManager.core.d.ts +54 -0
- package/dist/cleanupManager/cleanupManager.core.d.ts.map +1 -0
- package/dist/cleanupManager/cleanupManager.core.js +60 -0
- package/dist/cleanupManager/cleanupManager.core.js.map +1 -0
- package/dist/cleanupManager/index.d.ts +8 -0
- package/dist/cleanupManager/index.d.ts.map +1 -0
- package/dist/cleanupManager/index.js +7 -0
- package/dist/cleanupManager/index.js.map +1 -0
- package/dist/fixtures/eventFixtures.core.d.ts +53 -0
- package/dist/fixtures/eventFixtures.core.d.ts.map +1 -0
- package/dist/fixtures/eventFixtures.core.js +59 -0
- package/dist/fixtures/eventFixtures.core.js.map +1 -0
- package/dist/fixtures/index.d.ts +10 -0
- package/dist/fixtures/index.d.ts.map +1 -0
- package/dist/fixtures/index.js +8 -0
- package/dist/fixtures/index.js.map +1 -0
- package/dist/fixtures/messageFixtures.core.d.ts +53 -0
- package/dist/fixtures/messageFixtures.core.d.ts.map +1 -0
- package/dist/fixtures/messageFixtures.core.js +59 -0
- package/dist/fixtures/messageFixtures.core.js.map +1 -0
- package/dist/httpTesting/httpRequest.core.d.ts +69 -0
- package/dist/httpTesting/httpRequest.core.d.ts.map +1 -0
- package/dist/httpTesting/httpRequest.core.js +114 -0
- package/dist/httpTesting/httpRequest.core.js.map +1 -0
- package/dist/httpTesting/httpResponse.core.d.ts +20 -0
- package/dist/httpTesting/httpResponse.core.d.ts.map +1 -0
- package/dist/httpTesting/httpResponse.core.js +77 -0
- package/dist/httpTesting/httpResponse.core.js.map +1 -0
- package/dist/httpTesting/httpResponse.helpers.d.ts +24 -0
- package/dist/httpTesting/httpResponse.helpers.d.ts.map +1 -0
- package/dist/httpTesting/httpResponse.helpers.js +41 -0
- package/dist/httpTesting/httpResponse.helpers.js.map +1 -0
- package/dist/httpTesting/httpResponse.type.d.ts +25 -0
- package/dist/httpTesting/httpResponse.type.d.ts.map +1 -0
- package/dist/httpTesting/httpResponse.type.js +7 -0
- package/dist/httpTesting/httpResponse.type.js.map +1 -0
- package/dist/httpTesting/httpStatusCode.type.d.ts +10 -0
- package/dist/httpTesting/httpStatusCode.type.d.ts.map +1 -0
- package/dist/httpTesting/httpStatusCode.type.js +9 -0
- package/dist/httpTesting/httpStatusCode.type.js.map +1 -0
- package/dist/httpTesting/index.d.ts +11 -0
- package/dist/httpTesting/index.d.ts.map +1 -0
- package/dist/httpTesting/index.js +9 -0
- package/dist/httpTesting/index.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/mocking/index.d.ts +11 -0
- package/dist/mocking/index.d.ts.map +1 -0
- package/dist/mocking/index.js +9 -0
- package/dist/mocking/index.js.map +1 -0
- package/dist/mocking/mockFn.core.d.ts +40 -0
- package/dist/mocking/mockFn.core.d.ts.map +1 -0
- package/dist/mocking/mockFn.core.js +104 -0
- package/dist/mocking/mockFn.core.js.map +1 -0
- package/dist/mocking/spy.core.d.ts +66 -0
- package/dist/mocking/spy.core.d.ts.map +1 -0
- package/dist/mocking/spy.core.js +100 -0
- package/dist/mocking/spy.core.js.map +1 -0
- package/dist/mocking/stub.core.d.ts +56 -0
- package/dist/mocking/stub.core.d.ts.map +1 -0
- package/dist/mocking/stub.core.js +77 -0
- package/dist/mocking/stub.core.js.map +1 -0
- package/dist/spyLogger/index.d.ts +8 -0
- package/dist/spyLogger/index.d.ts.map +1 -0
- package/dist/spyLogger/index.js +7 -0
- package/dist/spyLogger/index.js.map +1 -0
- package/dist/spyLogger/spyLogger.core.d.ts +16 -0
- package/dist/spyLogger/spyLogger.core.d.ts.map +1 -0
- package/dist/spyLogger/spyLogger.core.js +69 -0
- package/dist/spyLogger/spyLogger.core.js.map +1 -0
- package/dist/spyLogger/spyLogger.type.d.ts +23 -0
- package/dist/spyLogger/spyLogger.type.d.ts.map +1 -0
- package/dist/spyLogger/spyLogger.type.js +7 -0
- package/dist/spyLogger/spyLogger.type.js.map +1 -0
- package/dist/testApplication/index.d.ts +8 -0
- package/dist/testApplication/index.d.ts.map +1 -0
- package/dist/testApplication/index.js +7 -0
- package/dist/testApplication/index.js.map +1 -0
- package/dist/testApplication/testApplication.core.d.ts +49 -0
- package/dist/testApplication/testApplication.core.d.ts.map +1 -0
- package/dist/testApplication/testApplication.core.js +51 -0
- package/dist/testApplication/testApplication.core.js.map +1 -0
- package/dist/testClock/index.d.ts +8 -0
- package/dist/testClock/index.d.ts.map +1 -0
- package/dist/testClock/index.js +7 -0
- package/dist/testClock/index.js.map +1 -0
- package/dist/testClock/testClock.core.d.ts +54 -0
- package/dist/testClock/testClock.core.d.ts.map +1 -0
- package/dist/testClock/testClock.core.js +57 -0
- package/dist/testClock/testClock.core.js.map +1 -0
- package/dist/testConfig/index.d.ts +8 -0
- package/dist/testConfig/index.d.ts.map +1 -0
- package/dist/testConfig/index.js +7 -0
- package/dist/testConfig/index.js.map +1 -0
- package/dist/testConfig/testConfig.core.d.ts +58 -0
- package/dist/testConfig/testConfig.core.d.ts.map +1 -0
- package/dist/testConfig/testConfig.core.js +53 -0
- package/dist/testConfig/testConfig.core.js.map +1 -0
- package/dist/testContainer/index.d.ts +8 -0
- package/dist/testContainer/index.d.ts.map +1 -0
- package/dist/testContainer/index.js +7 -0
- package/dist/testContainer/index.js.map +1 -0
- package/dist/testContainer/testContainer.core.d.ts +60 -0
- package/dist/testContainer/testContainer.core.d.ts.map +1 -0
- package/dist/testContainer/testContainer.core.js +47 -0
- package/dist/testContainer/testContainer.core.js.map +1 -0
- package/dist/testContext/index.d.ts +10 -0
- package/dist/testContext/index.d.ts.map +1 -0
- package/dist/testContext/index.js +8 -0
- package/dist/testContext/index.js.map +1 -0
- package/dist/testContext/testContext.core.d.ts +32 -0
- package/dist/testContext/testContext.core.d.ts.map +1 -0
- package/dist/testContext/testContext.core.js +28 -0
- package/dist/testContext/testContext.core.js.map +1 -0
- package/dist/testContext/testContext.recorder.core.d.ts +19 -0
- package/dist/testContext/testContext.recorder.core.d.ts.map +1 -0
- package/dist/testContext/testContext.recorder.core.js +74 -0
- package/dist/testContext/testContext.recorder.core.js.map +1 -0
- package/dist/testContext/testContext.recorder.type.d.ts +59 -0
- package/dist/testContext/testContext.recorder.type.d.ts.map +1 -0
- package/dist/testContext/testContext.recorder.type.js +7 -0
- package/dist/testContext/testContext.recorder.type.js.map +1 -0
- package/dist/testEventBus/index.d.ts +8 -0
- package/dist/testEventBus/index.d.ts.map +1 -0
- package/dist/testEventBus/index.js +7 -0
- package/dist/testEventBus/index.js.map +1 -0
- package/dist/testEventBus/testEventBus.core.d.ts +61 -0
- package/dist/testEventBus/testEventBus.core.d.ts.map +1 -0
- package/dist/testEventBus/testEventBus.core.js +61 -0
- package/dist/testEventBus/testEventBus.core.js.map +1 -0
- package/dist/testMessageBus/index.d.ts +8 -0
- package/dist/testMessageBus/index.d.ts.map +1 -0
- package/dist/testMessageBus/index.js +7 -0
- package/dist/testMessageBus/index.js.map +1 -0
- package/dist/testMessageBus/testMessageBus.core.d.ts +61 -0
- package/dist/testMessageBus/testMessageBus.core.d.ts.map +1 -0
- package/dist/testMessageBus/testMessageBus.core.js +61 -0
- package/dist/testMessageBus/testMessageBus.core.js.map +1 -0
- package/dist/testQueue/index.d.ts +8 -0
- package/dist/testQueue/index.d.ts.map +1 -0
- package/dist/testQueue/index.js +7 -0
- package/dist/testQueue/index.js.map +1 -0
- package/dist/testQueue/testQueue.core.d.ts +46 -0
- package/dist/testQueue/testQueue.core.d.ts.map +1 -0
- package/dist/testQueue/testQueue.core.js +36 -0
- package/dist/testQueue/testQueue.core.js.map +1 -0
- package/dist/testSerialization/index.d.ts +7 -0
- package/dist/testSerialization/index.d.ts.map +1 -0
- package/dist/testSerialization/index.js +7 -0
- package/dist/testSerialization/index.js.map +1 -0
- package/dist/testSerialization/serializationAssertions.core.d.ts +37 -0
- package/dist/testSerialization/serializationAssertions.core.d.ts.map +1 -0
- package/dist/testSerialization/serializationAssertions.core.js +63 -0
- package/dist/testSerialization/serializationAssertions.core.js.map +1 -0
- package/dist/testStorage/index.d.ts +7 -0
- package/dist/testStorage/index.d.ts.map +1 -0
- package/dist/testStorage/index.js +7 -0
- package/dist/testStorage/index.js.map +1 -0
- package/dist/testStorage/testStorageMemory.core.d.ts +30 -0
- package/dist/testStorage/testStorageMemory.core.d.ts.map +1 -0
- package/dist/testStorage/testStorageMemory.core.js +52 -0
- package/dist/testStorage/testStorageMemory.core.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error assertion helpers.
|
|
3
|
+
*
|
|
4
|
+
* Assert errors, error types, and error messages.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Asserts that a function throws an error.
|
|
8
|
+
*
|
|
9
|
+
* @param fn - The function to call.
|
|
10
|
+
* @param expectedMessage - Optional expected error message substring.
|
|
11
|
+
* @returns The thrown error.
|
|
12
|
+
*/
|
|
13
|
+
export declare function assertThrows(fn: () => unknown, expectedMessage?: string): Error;
|
|
14
|
+
/**
|
|
15
|
+
* Asserts that an async function rejects.
|
|
16
|
+
*
|
|
17
|
+
* @param fn - The async function to call.
|
|
18
|
+
* @param expectedMessage - Optional expected error message substring.
|
|
19
|
+
* @returns The rejected error.
|
|
20
|
+
*/
|
|
21
|
+
export declare function assertRejects(fn: () => Promise<unknown>, expectedMessage?: string): Promise<Error>;
|
|
22
|
+
/**
|
|
23
|
+
* Asserts that an error is a BaseError with a specific code.
|
|
24
|
+
*
|
|
25
|
+
* @param error - The error to check.
|
|
26
|
+
* @param code - Expected error code.
|
|
27
|
+
*/
|
|
28
|
+
export declare function assertErrorCode(error: unknown, code: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Asserts that an error has specific metadata.
|
|
31
|
+
*
|
|
32
|
+
* @param error - The error to check.
|
|
33
|
+
* @param key - Metadata key.
|
|
34
|
+
* @param value - Expected metadata value.
|
|
35
|
+
*/
|
|
36
|
+
export declare function assertErrorMetadata(error: unknown, key: string, value: unknown): void;
|
|
37
|
+
//# sourceMappingURL=errorAssertions.core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorAssertions.core.d.ts","sourceRoot":"","sources":["../../src/assertions/errorAssertions.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,OAAO,EACjB,eAAe,CAAC,EAAE,MAAM,GACvB,KAAK,CAgBP;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,EAAE,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EAC1B,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,KAAK,CAAC,CAgBhB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAYlE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,OAAO,GACb,IAAI,CAeN"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error assertion helpers.
|
|
3
|
+
*
|
|
4
|
+
* Assert errors, error types, and error messages.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Asserts that a function throws an error.
|
|
8
|
+
*
|
|
9
|
+
* @param fn - The function to call.
|
|
10
|
+
* @param expectedMessage - Optional expected error message substring.
|
|
11
|
+
* @returns The thrown error.
|
|
12
|
+
*/
|
|
13
|
+
export function assertThrows(fn, expectedMessage) {
|
|
14
|
+
try {
|
|
15
|
+
fn();
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (expectedMessage !== undefined) {
|
|
19
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
20
|
+
if (!message.includes(expectedMessage)) {
|
|
21
|
+
throw new Error(`Expected error message to contain "${expectedMessage}", got "${message}".`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
25
|
+
}
|
|
26
|
+
throw new Error("Expected function to throw, but it did not.");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Asserts that an async function rejects.
|
|
30
|
+
*
|
|
31
|
+
* @param fn - The async function to call.
|
|
32
|
+
* @param expectedMessage - Optional expected error message substring.
|
|
33
|
+
* @returns The rejected error.
|
|
34
|
+
*/
|
|
35
|
+
export async function assertRejects(fn, expectedMessage) {
|
|
36
|
+
try {
|
|
37
|
+
await fn();
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (expectedMessage !== undefined) {
|
|
41
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
42
|
+
if (!message.includes(expectedMessage)) {
|
|
43
|
+
throw new Error(`Expected error message to contain "${expectedMessage}", got "${message}".`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
47
|
+
}
|
|
48
|
+
throw new Error("Expected function to reject, but it did not.");
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Asserts that an error is a BaseError with a specific code.
|
|
52
|
+
*
|
|
53
|
+
* @param error - The error to check.
|
|
54
|
+
* @param code - Expected error code.
|
|
55
|
+
*/
|
|
56
|
+
export function assertErrorCode(error, code) {
|
|
57
|
+
if (!(error instanceof Error)) {
|
|
58
|
+
throw new Error(`Expected error to be an Error instance, got ${typeof error}.`);
|
|
59
|
+
}
|
|
60
|
+
const baseError = error;
|
|
61
|
+
if (baseError.code !== code) {
|
|
62
|
+
throw new Error(`Expected error code "${code}", got "${baseError.code}".`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Asserts that an error has specific metadata.
|
|
67
|
+
*
|
|
68
|
+
* @param error - The error to check.
|
|
69
|
+
* @param key - Metadata key.
|
|
70
|
+
* @param value - Expected metadata value.
|
|
71
|
+
*/
|
|
72
|
+
export function assertErrorMetadata(error, key, value) {
|
|
73
|
+
if (!(error instanceof Error)) {
|
|
74
|
+
throw new Error(`Expected error to be an Error instance, got ${typeof error}.`);
|
|
75
|
+
}
|
|
76
|
+
const baseError = error;
|
|
77
|
+
const actual = baseError.metadata?.[key];
|
|
78
|
+
if (actual !== value) {
|
|
79
|
+
throw new Error(`Expected error metadata "${key}" to be "${value}", got "${actual}".`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=errorAssertions.core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorAssertions.core.js","sourceRoot":"","sources":["../../src/assertions/errorAssertions.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,EAAiB,EACjB,eAAwB;IAExB,IAAI,CAAC;QACH,EAAE,EAAE,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,KAAK,CAAC,8CAA8C,CAAC,CAAC;AAClE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc,EAAE,IAAY;IAC1D,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,+CAA+C,OAAO,KAAK,GAAG,CAC/D,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,KAAkB,CAAC;IAErC,IAAI,SAAS,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,WAAW,SAAS,CAAC,IAAI,IAAI,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAc,EACd,GAAW,EACX,KAAc;IAEd,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,+CAA+C,OAAO,KAAK,GAAG,CAC/D,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,KAAkB,CAAC;IACrC,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IAEzC,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,4BAA4B,GAAG,YAAY,KAAK,WAAW,MAAM,IAAI,CACtE,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event assertion helpers.
|
|
3
|
+
*
|
|
4
|
+
* Assert events, event types, and event payloads.
|
|
5
|
+
*/
|
|
6
|
+
import type { Event } from "@zudojs/events";
|
|
7
|
+
import type { RecordedEvent } from "../testEventBus/testEventBus.core.js";
|
|
8
|
+
import type { RecordedMessage } from "../testMessageBus/testMessageBus.core.js";
|
|
9
|
+
/**
|
|
10
|
+
* Asserts that an event has a specific type.
|
|
11
|
+
*
|
|
12
|
+
* @param event - The event to check.
|
|
13
|
+
* @param type - Expected event type.
|
|
14
|
+
*/
|
|
15
|
+
export declare function assertEventType<TPayload>(event: Event<TPayload>, type: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Asserts that an event payload matches expected value.
|
|
18
|
+
*
|
|
19
|
+
* @param event - The event to check.
|
|
20
|
+
* @param expected - Expected payload.
|
|
21
|
+
*/
|
|
22
|
+
export declare function assertEventPayload<TPayload>(event: Event<TPayload>, expected: TPayload): void;
|
|
23
|
+
/**
|
|
24
|
+
* Asserts that a recorded event has a specific type.
|
|
25
|
+
*
|
|
26
|
+
* @param recorded - The recorded event.
|
|
27
|
+
* @param type - Expected event type.
|
|
28
|
+
*/
|
|
29
|
+
export declare function assertRecordedEventType<TPayload>(recorded: RecordedEvent<TPayload>, type: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Asserts that an array of recorded events contains at least one event of a type.
|
|
32
|
+
*
|
|
33
|
+
* @param events - Array of recorded events.
|
|
34
|
+
* @param type - Expected event type.
|
|
35
|
+
*/
|
|
36
|
+
export declare function assertEventPublished<TPayload>(events: readonly RecordedEvent<TPayload>[], type: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Asserts that an array of recorded messages contains at least one message of a type.
|
|
39
|
+
*
|
|
40
|
+
* @param messages - Array of recorded messages.
|
|
41
|
+
* @param type - Expected message type.
|
|
42
|
+
*/
|
|
43
|
+
export declare function assertMessageDispatched<TPayload>(messages: readonly RecordedMessage<TPayload>[], type: string): void;
|
|
44
|
+
//# sourceMappingURL=eventAssertions.core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventAssertions.core.d.ts","sourceRoot":"","sources":["../../src/assertions/eventAssertions.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEhF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EACtC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,EACtB,IAAI,EAAE,MAAM,GACX,IAAI,CAIN;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EACzC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,EACtB,QAAQ,EAAE,QAAQ,GACjB,IAAI,CAON;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAC9C,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,EACjC,IAAI,EAAE,MAAM,GACX,IAAI,CAEN;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAC3C,MAAM,EAAE,SAAS,aAAa,CAAC,QAAQ,CAAC,EAAE,EAC1C,IAAI,EAAE,MAAM,GACX,IAAI,CAON;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAC9C,QAAQ,EAAE,SAAS,eAAe,CAAC,QAAQ,CAAC,EAAE,EAC9C,IAAI,EAAE,MAAM,GACX,IAAI,CAON"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event assertion helpers.
|
|
3
|
+
*
|
|
4
|
+
* Assert events, event types, and event payloads.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Asserts that an event has a specific type.
|
|
8
|
+
*
|
|
9
|
+
* @param event - The event to check.
|
|
10
|
+
* @param type - Expected event type.
|
|
11
|
+
*/
|
|
12
|
+
export function assertEventType(event, type) {
|
|
13
|
+
if (event.type !== type) {
|
|
14
|
+
throw new Error(`Expected event type "${type}", got "${event.type}".`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Asserts that an event payload matches expected value.
|
|
19
|
+
*
|
|
20
|
+
* @param event - The event to check.
|
|
21
|
+
* @param expected - Expected payload.
|
|
22
|
+
*/
|
|
23
|
+
export function assertEventPayload(event, expected) {
|
|
24
|
+
const actual = JSON.stringify(event.payload);
|
|
25
|
+
const expectedJson = JSON.stringify(expected);
|
|
26
|
+
if (actual !== expectedJson) {
|
|
27
|
+
throw new Error(`Expected event payload ${expectedJson}, got ${actual}.`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Asserts that a recorded event has a specific type.
|
|
32
|
+
*
|
|
33
|
+
* @param recorded - The recorded event.
|
|
34
|
+
* @param type - Expected event type.
|
|
35
|
+
*/
|
|
36
|
+
export function assertRecordedEventType(recorded, type) {
|
|
37
|
+
assertEventType(recorded.event, type);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Asserts that an array of recorded events contains at least one event of a type.
|
|
41
|
+
*
|
|
42
|
+
* @param events - Array of recorded events.
|
|
43
|
+
* @param type - Expected event type.
|
|
44
|
+
*/
|
|
45
|
+
export function assertEventPublished(events, type) {
|
|
46
|
+
const found = events.some((e) => e.event.type === type);
|
|
47
|
+
if (!found) {
|
|
48
|
+
throw new Error(`Expected event "${type}" to be published, but it was not found.`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Asserts that an array of recorded messages contains at least one message of a type.
|
|
53
|
+
*
|
|
54
|
+
* @param messages - Array of recorded messages.
|
|
55
|
+
* @param type - Expected message type.
|
|
56
|
+
*/
|
|
57
|
+
export function assertMessageDispatched(messages, type) {
|
|
58
|
+
const found = messages.some((m) => m.message.type === type);
|
|
59
|
+
if (!found) {
|
|
60
|
+
throw new Error(`Expected message "${type}" to be dispatched, but it was not found.`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=eventAssertions.core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventAssertions.core.js","sourceRoot":"","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C,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC5D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,qBAAqB,IAAI,2CAA2C,CACrE,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP assertion helpers.
|
|
3
|
+
*
|
|
4
|
+
* Assert HTTP responses, status codes, headers, and bodies.
|
|
5
|
+
*/
|
|
6
|
+
import type { HTTPStatusCode } from "../httpTesting/httpStatusCode.type.js";
|
|
7
|
+
import type { TestHTTPResponse } from "../httpTesting/httpResponse.type.js";
|
|
8
|
+
/**
|
|
9
|
+
* Asserts that a response has a specific status code.
|
|
10
|
+
*
|
|
11
|
+
* @param response - The test response.
|
|
12
|
+
* @param expected - Expected status code.
|
|
13
|
+
*/
|
|
14
|
+
export declare function assertResponseStatus(response: TestHTTPResponse, expected: HTTPStatusCode): void;
|
|
15
|
+
/**
|
|
16
|
+
* Asserts that a response has a specific header value.
|
|
17
|
+
*
|
|
18
|
+
* @param response - The test response.
|
|
19
|
+
* @param header - Header name.
|
|
20
|
+
* @param value - Expected header value.
|
|
21
|
+
*/
|
|
22
|
+
export declare function assertResponseHeader(response: TestHTTPResponse, header: string, value: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Asserts that a response body matches expected JSON.
|
|
25
|
+
*
|
|
26
|
+
* @param response - The test response.
|
|
27
|
+
* @param expected - Expected body.
|
|
28
|
+
*/
|
|
29
|
+
export declare function assertResponseBody(response: TestHTTPResponse, expected: unknown): void;
|
|
30
|
+
/**
|
|
31
|
+
* Asserts that a response is 200 OK.
|
|
32
|
+
*/
|
|
33
|
+
export declare function assertOK(response: TestHTTPResponse): void;
|
|
34
|
+
/**
|
|
35
|
+
* Asserts that a response is 201 Created.
|
|
36
|
+
*/
|
|
37
|
+
export declare function assertCreated(response: TestHTTPResponse): void;
|
|
38
|
+
/**
|
|
39
|
+
* Asserts that a response is 204 No Content.
|
|
40
|
+
*/
|
|
41
|
+
export declare function assertNoContent(response: TestHTTPResponse): void;
|
|
42
|
+
/**
|
|
43
|
+
* Asserts that a response is 400 Bad Request.
|
|
44
|
+
*/
|
|
45
|
+
export declare function assertBadRequest(response: TestHTTPResponse): void;
|
|
46
|
+
/**
|
|
47
|
+
* Asserts that a response is 404 Not Found.
|
|
48
|
+
*/
|
|
49
|
+
export declare function assertNotFound(response: TestHTTPResponse): void;
|
|
50
|
+
/**
|
|
51
|
+
* Asserts that a response is 500 Internal Server Error.
|
|
52
|
+
*/
|
|
53
|
+
export declare function assertServerError(response: TestHTTPResponse): void;
|
|
54
|
+
//# sourceMappingURL=httpAssertions.core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpAssertions.core.d.ts","sourceRoot":"","sources":["../../src/assertions/httpAssertions.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAE5E;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,cAAc,GACvB,IAAI,CAIN;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,IAAI,CAON;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,OAAO,GAChB,IAAI,CAQN;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAEzD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAE9D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAEhE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAEjE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAE/D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAElE"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP assertion helpers.
|
|
3
|
+
*
|
|
4
|
+
* Assert HTTP responses, status codes, headers, and bodies.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Asserts that a response has a specific status code.
|
|
8
|
+
*
|
|
9
|
+
* @param response - The test response.
|
|
10
|
+
* @param expected - Expected status code.
|
|
11
|
+
*/
|
|
12
|
+
export function assertResponseStatus(response, expected) {
|
|
13
|
+
if (response.status !== expected) {
|
|
14
|
+
throw new Error(`Expected status ${expected}, got ${response.status}.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Asserts that a response has a specific header value.
|
|
19
|
+
*
|
|
20
|
+
* @param response - The test response.
|
|
21
|
+
* @param header - Header name.
|
|
22
|
+
* @param value - Expected header value.
|
|
23
|
+
*/
|
|
24
|
+
export function assertResponseHeader(response, header, value) {
|
|
25
|
+
const actual = response.headers.get(header.toLowerCase());
|
|
26
|
+
if (actual !== value) {
|
|
27
|
+
throw new Error(`Expected header "${header}" to be "${value}", got "${actual}".`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Asserts that a response body matches expected JSON.
|
|
32
|
+
*
|
|
33
|
+
* @param response - The test response.
|
|
34
|
+
* @param expected - Expected body.
|
|
35
|
+
*/
|
|
36
|
+
export function assertResponseBody(response, expected) {
|
|
37
|
+
const actual = response.body;
|
|
38
|
+
const actualJson = JSON.stringify(actual);
|
|
39
|
+
const expectedJson = JSON.stringify(expected);
|
|
40
|
+
if (actualJson !== expectedJson) {
|
|
41
|
+
throw new Error(`Expected body ${expectedJson}, got ${actualJson}.`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Asserts that a response is 200 OK.
|
|
46
|
+
*/
|
|
47
|
+
export function assertOK(response) {
|
|
48
|
+
assertResponseStatus(response, 200);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Asserts that a response is 201 Created.
|
|
52
|
+
*/
|
|
53
|
+
export function assertCreated(response) {
|
|
54
|
+
assertResponseStatus(response, 201);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Asserts that a response is 204 No Content.
|
|
58
|
+
*/
|
|
59
|
+
export function assertNoContent(response) {
|
|
60
|
+
assertResponseStatus(response, 204);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Asserts that a response is 400 Bad Request.
|
|
64
|
+
*/
|
|
65
|
+
export function assertBadRequest(response) {
|
|
66
|
+
assertResponseStatus(response, 400);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Asserts that a response is 404 Not Found.
|
|
70
|
+
*/
|
|
71
|
+
export function assertNotFound(response) {
|
|
72
|
+
assertResponseStatus(response, 404);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Asserts that a response is 500 Internal Server Error.
|
|
76
|
+
*/
|
|
77
|
+
export function assertServerError(response) {
|
|
78
|
+
assertResponseStatus(response, 500);
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=httpAssertions.core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpAssertions.core.js","sourceRoot":"","sources":["../../src/assertions/httpAssertions.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;;;;GAKG;AACH,MAAM,UAAU,oBAA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GAAG,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAA0B;IACzD,oBAAoB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,QAA0B;IACvD,oBAAoB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAA0B;IAC1D,oBAAoB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assertion helpers.
|
|
3
|
+
*
|
|
4
|
+
* HTTP, error, and event assertion utilities.
|
|
5
|
+
*/
|
|
6
|
+
export { assertResponseStatus, assertResponseHeader, assertResponseBody, assertOK, assertCreated, assertNoContent, assertBadRequest, assertNotFound, assertServerError, } from "./httpAssertions.core.js";
|
|
7
|
+
export { assertThrows, assertRejects, assertErrorCode, assertErrorMetadata, } from "./errorAssertions.core.js";
|
|
8
|
+
export { assertEventType, assertEventPayload, assertRecordedEventType, assertEventPublished, assertMessageDispatched, } from "./eventAssertions.core.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/assertions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,QAAQ,EACR,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,YAAY,EACZ,aAAa,EACb,eAAe,EACf,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assertion helpers.
|
|
3
|
+
*
|
|
4
|
+
* HTTP, error, and event assertion utilities.
|
|
5
|
+
*/
|
|
6
|
+
export { assertResponseStatus, assertResponseHeader, assertResponseBody, assertOK, assertCreated, assertNoContent, assertBadRequest, assertNotFound, assertServerError, } from "./httpAssertions.core.js";
|
|
7
|
+
export { assertThrows, assertRejects, assertErrorCode, assertErrorMetadata, } from "./errorAssertions.core.js";
|
|
8
|
+
export { assertEventType, assertEventPayload, assertRecordedEventType, assertEventPublished, assertMessageDispatched, } from "./eventAssertions.core.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/assertions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,QAAQ,EACR,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,YAAY,EACZ,aAAa,EACb,eAAe,EACf,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cleanup manager for test resources.
|
|
3
|
+
*
|
|
4
|
+
* Registers cleanup functions during tests and executes them
|
|
5
|
+
* in reverse order on dispose. Handles errors safely to ensure
|
|
6
|
+
* all cleanups run even if one fails.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A registered cleanup function with metadata.
|
|
10
|
+
*/
|
|
11
|
+
export interface CleanupEntry {
|
|
12
|
+
readonly id: number;
|
|
13
|
+
readonly label: string;
|
|
14
|
+
readonly fn: () => Promise<void> | void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Options for the cleanup manager.
|
|
18
|
+
*/
|
|
19
|
+
export interface CleanupManagerOptions {
|
|
20
|
+
readonly label?: string;
|
|
21
|
+
readonly onError?: (error: unknown, entry: CleanupEntry) => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Manages test resource cleanup.
|
|
25
|
+
*
|
|
26
|
+
* Registers cleanup functions and executes them in reverse order
|
|
27
|
+
* when `dispose()` is called. Protects against open handles,
|
|
28
|
+
* timers, database connections, and other resources leaking
|
|
29
|
+
* after tests complete.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const cleanup = createCleanupManager();
|
|
34
|
+
*
|
|
35
|
+
* cleanup.register(() => database.close());
|
|
36
|
+
* cleanup.register(() => server.stop());
|
|
37
|
+
*
|
|
38
|
+
* await cleanup.dispose();
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export interface CleanupManager {
|
|
42
|
+
readonly disposed: boolean;
|
|
43
|
+
readonly count: number;
|
|
44
|
+
register: (fn: () => Promise<void> | void, label?: string) => void;
|
|
45
|
+
dispose: () => Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates a cleanup manager for test resources.
|
|
49
|
+
*
|
|
50
|
+
* @param options - Configuration for the cleanup manager.
|
|
51
|
+
* @returns A new CleanupManager instance.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createCleanupManager(options?: CleanupManagerOptions): CleanupManager;
|
|
54
|
+
//# sourceMappingURL=cleanupManager.core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanupManager.core.d.ts","sourceRoot":"","sources":["../../src/cleanupManager/cleanupManager.core.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;CAClE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnE,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,qBAA0B,GAClC,cAAc,CA8DhB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cleanup manager for test resources.
|
|
3
|
+
*
|
|
4
|
+
* Registers cleanup functions during tests and executes them
|
|
5
|
+
* in reverse order on dispose. Handles errors safely to ensure
|
|
6
|
+
* all cleanups run even if one fails.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Creates a cleanup manager for test resources.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Configuration for the cleanup manager.
|
|
12
|
+
* @returns A new CleanupManager instance.
|
|
13
|
+
*/
|
|
14
|
+
export function createCleanupManager(options = {}) {
|
|
15
|
+
const entries = [];
|
|
16
|
+
let nextId = 0;
|
|
17
|
+
let disposed = false;
|
|
18
|
+
const register = (fn, label = `cleanup-${nextId}`) => {
|
|
19
|
+
if (disposed) {
|
|
20
|
+
throw new Error("Cannot register cleanup after manager has been disposed.");
|
|
21
|
+
}
|
|
22
|
+
entries.push({
|
|
23
|
+
id: nextId++,
|
|
24
|
+
label,
|
|
25
|
+
fn,
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const dispose = async () => {
|
|
29
|
+
if (disposed) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
disposed = true;
|
|
33
|
+
const errors = [];
|
|
34
|
+
const reversed = [...entries].reverse();
|
|
35
|
+
for (const entry of reversed) {
|
|
36
|
+
try {
|
|
37
|
+
await entry.fn();
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
errors.push({ entry, error });
|
|
41
|
+
options.onError?.(error, entry);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
entries.length = 0;
|
|
45
|
+
if (errors.length > 0 && errors.length === entries.length) {
|
|
46
|
+
throw new Error(`All ${errors.length} cleanup functions failed.`);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
get disposed() {
|
|
51
|
+
return disposed;
|
|
52
|
+
},
|
|
53
|
+
get count() {
|
|
54
|
+
return entries.length;
|
|
55
|
+
},
|
|
56
|
+
register,
|
|
57
|
+
dispose,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=cleanupManager.core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanupManager.core.js","sourceRoot":"","sources":["../../src/cleanupManager/cleanupManager.core.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA4CH;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAO,GAA0B,EAAE;IAEnC,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,QAAQ,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ACxB,CAAC;QACD,QAAQ;QACR,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test cleanup manager.
|
|
3
|
+
*
|
|
4
|
+
* Registers and executes resource cleanup functions in reverse order.
|
|
5
|
+
*/
|
|
6
|
+
export { createCleanupManager } from "./cleanupManager.core.js";
|
|
7
|
+
export type { CleanupEntry, CleanupManager, CleanupManagerOptions, } from "./cleanupManager.core.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cleanupManager/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,YAAY,EACV,YAAY,EACZ,cAAc,EACd,qBAAqB,GACtB,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cleanupManager/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event fixtures for testing.
|
|
3
|
+
*
|
|
4
|
+
* Factory functions for creating test event payloads.
|
|
5
|
+
*/
|
|
6
|
+
import type { Event, EventInput } from "@zudojs/events";
|
|
7
|
+
import type { EventId } from "@zudojs/constants";
|
|
8
|
+
/**
|
|
9
|
+
* Options for creating a test event.
|
|
10
|
+
*/
|
|
11
|
+
export interface CreateEventOptions<TPayload> {
|
|
12
|
+
readonly type?: string;
|
|
13
|
+
readonly payload?: TPayload;
|
|
14
|
+
readonly id?: EventId;
|
|
15
|
+
readonly timestamp?: Date;
|
|
16
|
+
readonly metadata?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a test event.
|
|
20
|
+
*
|
|
21
|
+
* @param options - Event options.
|
|
22
|
+
* @returns A test Event instance.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const event = createEvent<{ userId: string }>({
|
|
27
|
+
* type: "user.created",
|
|
28
|
+
* payload: { userId: "123" },
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* expect(event.type).toBe("user.created");
|
|
32
|
+
* expect(event.payload).toEqual({ userId: "123" });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function createEvent<TPayload = unknown>(options?: CreateEventOptions<TPayload>): Event<TPayload>;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a test event input.
|
|
38
|
+
*
|
|
39
|
+
* @param type - Event type.
|
|
40
|
+
* @param payload - Event payload.
|
|
41
|
+
* @param metadata - Optional metadata.
|
|
42
|
+
* @returns An EventInput instance.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createEventInput<TPayload>(type: string, payload: TPayload, metadata?: Record<string, unknown>): EventInput<TPayload>;
|
|
45
|
+
/**
|
|
46
|
+
* Creates multiple test events.
|
|
47
|
+
*
|
|
48
|
+
* @param count - Number of events to create.
|
|
49
|
+
* @param factory - Factory function for each event.
|
|
50
|
+
* @returns Array of test Events.
|
|
51
|
+
*/
|
|
52
|
+
export declare function createEvents<TPayload>(count: number, factory: (index: number) => CreateEventOptions<TPayload>): Event<TPayload>[];
|
|
53
|
+
//# sourceMappingURL=eventFixtures.core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventFixtures.core.d.ts","sourceRoot":"","sources":["../../src/fixtures/eventFixtures.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,QAAQ;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C;AAID;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,QAAQ,GAAG,OAAO,EAC5C,OAAO,GAAE,kBAAkB,CAAC,QAAQ,CAAM,GACzC,KAAK,CAAC,QAAQ,CAAC,CAUjB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,QAAQ,EACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,UAAU,CAAC,QAAQ,CAAC,CAMtB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EACnC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,kBAAkB,CAAC,QAAQ,CAAC,GACvD,KAAK,CAAC,QAAQ,CAAC,EAAE,CAEnB"}
|