@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.
Files changed (183) hide show
  1. package/README.md +35 -0
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/assertions/errorAssertions.core.d.ts +37 -0
  4. package/dist/assertions/errorAssertions.core.d.ts.map +1 -0
  5. package/dist/assertions/errorAssertions.core.js +82 -0
  6. package/dist/assertions/errorAssertions.core.js.map +1 -0
  7. package/dist/assertions/eventAssertions.core.d.ts +44 -0
  8. package/dist/assertions/eventAssertions.core.d.ts.map +1 -0
  9. package/dist/assertions/eventAssertions.core.js +63 -0
  10. package/dist/assertions/eventAssertions.core.js.map +1 -0
  11. package/dist/assertions/httpAssertions.core.d.ts +54 -0
  12. package/dist/assertions/httpAssertions.core.d.ts.map +1 -0
  13. package/dist/assertions/httpAssertions.core.js +80 -0
  14. package/dist/assertions/httpAssertions.core.js.map +1 -0
  15. package/dist/assertions/index.d.ts +9 -0
  16. package/dist/assertions/index.d.ts.map +1 -0
  17. package/dist/assertions/index.js +9 -0
  18. package/dist/assertions/index.js.map +1 -0
  19. package/dist/cleanupManager/cleanupManager.core.d.ts +54 -0
  20. package/dist/cleanupManager/cleanupManager.core.d.ts.map +1 -0
  21. package/dist/cleanupManager/cleanupManager.core.js +60 -0
  22. package/dist/cleanupManager/cleanupManager.core.js.map +1 -0
  23. package/dist/cleanupManager/index.d.ts +8 -0
  24. package/dist/cleanupManager/index.d.ts.map +1 -0
  25. package/dist/cleanupManager/index.js +7 -0
  26. package/dist/cleanupManager/index.js.map +1 -0
  27. package/dist/fixtures/eventFixtures.core.d.ts +53 -0
  28. package/dist/fixtures/eventFixtures.core.d.ts.map +1 -0
  29. package/dist/fixtures/eventFixtures.core.js +59 -0
  30. package/dist/fixtures/eventFixtures.core.js.map +1 -0
  31. package/dist/fixtures/index.d.ts +10 -0
  32. package/dist/fixtures/index.d.ts.map +1 -0
  33. package/dist/fixtures/index.js +8 -0
  34. package/dist/fixtures/index.js.map +1 -0
  35. package/dist/fixtures/messageFixtures.core.d.ts +53 -0
  36. package/dist/fixtures/messageFixtures.core.d.ts.map +1 -0
  37. package/dist/fixtures/messageFixtures.core.js +59 -0
  38. package/dist/fixtures/messageFixtures.core.js.map +1 -0
  39. package/dist/httpTesting/httpRequest.core.d.ts +69 -0
  40. package/dist/httpTesting/httpRequest.core.d.ts.map +1 -0
  41. package/dist/httpTesting/httpRequest.core.js +114 -0
  42. package/dist/httpTesting/httpRequest.core.js.map +1 -0
  43. package/dist/httpTesting/httpResponse.core.d.ts +20 -0
  44. package/dist/httpTesting/httpResponse.core.d.ts.map +1 -0
  45. package/dist/httpTesting/httpResponse.core.js +77 -0
  46. package/dist/httpTesting/httpResponse.core.js.map +1 -0
  47. package/dist/httpTesting/httpResponse.helpers.d.ts +24 -0
  48. package/dist/httpTesting/httpResponse.helpers.d.ts.map +1 -0
  49. package/dist/httpTesting/httpResponse.helpers.js +41 -0
  50. package/dist/httpTesting/httpResponse.helpers.js.map +1 -0
  51. package/dist/httpTesting/httpResponse.type.d.ts +25 -0
  52. package/dist/httpTesting/httpResponse.type.d.ts.map +1 -0
  53. package/dist/httpTesting/httpResponse.type.js +7 -0
  54. package/dist/httpTesting/httpResponse.type.js.map +1 -0
  55. package/dist/httpTesting/httpStatusCode.type.d.ts +10 -0
  56. package/dist/httpTesting/httpStatusCode.type.d.ts.map +1 -0
  57. package/dist/httpTesting/httpStatusCode.type.js +9 -0
  58. package/dist/httpTesting/httpStatusCode.type.js.map +1 -0
  59. package/dist/httpTesting/index.d.ts +11 -0
  60. package/dist/httpTesting/index.d.ts.map +1 -0
  61. package/dist/httpTesting/index.js +9 -0
  62. package/dist/httpTesting/index.js.map +1 -0
  63. package/dist/index.d.ts +24 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +24 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/mocking/index.d.ts +11 -0
  68. package/dist/mocking/index.d.ts.map +1 -0
  69. package/dist/mocking/index.js +9 -0
  70. package/dist/mocking/index.js.map +1 -0
  71. package/dist/mocking/mockFn.core.d.ts +40 -0
  72. package/dist/mocking/mockFn.core.d.ts.map +1 -0
  73. package/dist/mocking/mockFn.core.js +104 -0
  74. package/dist/mocking/mockFn.core.js.map +1 -0
  75. package/dist/mocking/spy.core.d.ts +66 -0
  76. package/dist/mocking/spy.core.d.ts.map +1 -0
  77. package/dist/mocking/spy.core.js +100 -0
  78. package/dist/mocking/spy.core.js.map +1 -0
  79. package/dist/mocking/stub.core.d.ts +56 -0
  80. package/dist/mocking/stub.core.d.ts.map +1 -0
  81. package/dist/mocking/stub.core.js +77 -0
  82. package/dist/mocking/stub.core.js.map +1 -0
  83. package/dist/spyLogger/index.d.ts +8 -0
  84. package/dist/spyLogger/index.d.ts.map +1 -0
  85. package/dist/spyLogger/index.js +7 -0
  86. package/dist/spyLogger/index.js.map +1 -0
  87. package/dist/spyLogger/spyLogger.core.d.ts +16 -0
  88. package/dist/spyLogger/spyLogger.core.d.ts.map +1 -0
  89. package/dist/spyLogger/spyLogger.core.js +69 -0
  90. package/dist/spyLogger/spyLogger.core.js.map +1 -0
  91. package/dist/spyLogger/spyLogger.type.d.ts +23 -0
  92. package/dist/spyLogger/spyLogger.type.d.ts.map +1 -0
  93. package/dist/spyLogger/spyLogger.type.js +7 -0
  94. package/dist/spyLogger/spyLogger.type.js.map +1 -0
  95. package/dist/testApplication/index.d.ts +8 -0
  96. package/dist/testApplication/index.d.ts.map +1 -0
  97. package/dist/testApplication/index.js +7 -0
  98. package/dist/testApplication/index.js.map +1 -0
  99. package/dist/testApplication/testApplication.core.d.ts +49 -0
  100. package/dist/testApplication/testApplication.core.d.ts.map +1 -0
  101. package/dist/testApplication/testApplication.core.js +51 -0
  102. package/dist/testApplication/testApplication.core.js.map +1 -0
  103. package/dist/testClock/index.d.ts +8 -0
  104. package/dist/testClock/index.d.ts.map +1 -0
  105. package/dist/testClock/index.js +7 -0
  106. package/dist/testClock/index.js.map +1 -0
  107. package/dist/testClock/testClock.core.d.ts +54 -0
  108. package/dist/testClock/testClock.core.d.ts.map +1 -0
  109. package/dist/testClock/testClock.core.js +57 -0
  110. package/dist/testClock/testClock.core.js.map +1 -0
  111. package/dist/testConfig/index.d.ts +8 -0
  112. package/dist/testConfig/index.d.ts.map +1 -0
  113. package/dist/testConfig/index.js +7 -0
  114. package/dist/testConfig/index.js.map +1 -0
  115. package/dist/testConfig/testConfig.core.d.ts +58 -0
  116. package/dist/testConfig/testConfig.core.d.ts.map +1 -0
  117. package/dist/testConfig/testConfig.core.js +53 -0
  118. package/dist/testConfig/testConfig.core.js.map +1 -0
  119. package/dist/testContainer/index.d.ts +8 -0
  120. package/dist/testContainer/index.d.ts.map +1 -0
  121. package/dist/testContainer/index.js +7 -0
  122. package/dist/testContainer/index.js.map +1 -0
  123. package/dist/testContainer/testContainer.core.d.ts +60 -0
  124. package/dist/testContainer/testContainer.core.d.ts.map +1 -0
  125. package/dist/testContainer/testContainer.core.js +47 -0
  126. package/dist/testContainer/testContainer.core.js.map +1 -0
  127. package/dist/testContext/index.d.ts +10 -0
  128. package/dist/testContext/index.d.ts.map +1 -0
  129. package/dist/testContext/index.js +8 -0
  130. package/dist/testContext/index.js.map +1 -0
  131. package/dist/testContext/testContext.core.d.ts +32 -0
  132. package/dist/testContext/testContext.core.d.ts.map +1 -0
  133. package/dist/testContext/testContext.core.js +28 -0
  134. package/dist/testContext/testContext.core.js.map +1 -0
  135. package/dist/testContext/testContext.recorder.core.d.ts +19 -0
  136. package/dist/testContext/testContext.recorder.core.d.ts.map +1 -0
  137. package/dist/testContext/testContext.recorder.core.js +74 -0
  138. package/dist/testContext/testContext.recorder.core.js.map +1 -0
  139. package/dist/testContext/testContext.recorder.type.d.ts +59 -0
  140. package/dist/testContext/testContext.recorder.type.d.ts.map +1 -0
  141. package/dist/testContext/testContext.recorder.type.js +7 -0
  142. package/dist/testContext/testContext.recorder.type.js.map +1 -0
  143. package/dist/testEventBus/index.d.ts +8 -0
  144. package/dist/testEventBus/index.d.ts.map +1 -0
  145. package/dist/testEventBus/index.js +7 -0
  146. package/dist/testEventBus/index.js.map +1 -0
  147. package/dist/testEventBus/testEventBus.core.d.ts +61 -0
  148. package/dist/testEventBus/testEventBus.core.d.ts.map +1 -0
  149. package/dist/testEventBus/testEventBus.core.js +61 -0
  150. package/dist/testEventBus/testEventBus.core.js.map +1 -0
  151. package/dist/testMessageBus/index.d.ts +8 -0
  152. package/dist/testMessageBus/index.d.ts.map +1 -0
  153. package/dist/testMessageBus/index.js +7 -0
  154. package/dist/testMessageBus/index.js.map +1 -0
  155. package/dist/testMessageBus/testMessageBus.core.d.ts +61 -0
  156. package/dist/testMessageBus/testMessageBus.core.d.ts.map +1 -0
  157. package/dist/testMessageBus/testMessageBus.core.js +61 -0
  158. package/dist/testMessageBus/testMessageBus.core.js.map +1 -0
  159. package/dist/testQueue/index.d.ts +8 -0
  160. package/dist/testQueue/index.d.ts.map +1 -0
  161. package/dist/testQueue/index.js +7 -0
  162. package/dist/testQueue/index.js.map +1 -0
  163. package/dist/testQueue/testQueue.core.d.ts +46 -0
  164. package/dist/testQueue/testQueue.core.d.ts.map +1 -0
  165. package/dist/testQueue/testQueue.core.js +36 -0
  166. package/dist/testQueue/testQueue.core.js.map +1 -0
  167. package/dist/testSerialization/index.d.ts +7 -0
  168. package/dist/testSerialization/index.d.ts.map +1 -0
  169. package/dist/testSerialization/index.js +7 -0
  170. package/dist/testSerialization/index.js.map +1 -0
  171. package/dist/testSerialization/serializationAssertions.core.d.ts +37 -0
  172. package/dist/testSerialization/serializationAssertions.core.d.ts.map +1 -0
  173. package/dist/testSerialization/serializationAssertions.core.js +63 -0
  174. package/dist/testSerialization/serializationAssertions.core.js.map +1 -0
  175. package/dist/testStorage/index.d.ts +7 -0
  176. package/dist/testStorage/index.d.ts.map +1 -0
  177. package/dist/testStorage/index.js +7 -0
  178. package/dist/testStorage/index.js.map +1 -0
  179. package/dist/testStorage/testStorageMemory.core.d.ts +30 -0
  180. package/dist/testStorage/testStorageMemory.core.d.ts.map +1 -0
  181. package/dist/testStorage/testStorageMemory.core.js +52 -0
  182. package/dist/testStorage/testStorageMemory.core.js.map +1 -0
  183. package/package.json +64 -0
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Test container helpers.
3
+ *
4
+ * Wraps the real Zudojs container with test-friendly defaults
5
+ * and override support for dependency injection testing.
6
+ */
7
+ import { createStartedContainer } from "@zudojs/container";
8
+ /**
9
+ * Creates a pre-started test container with optional overrides.
10
+ *
11
+ * @param options - Test container configuration.
12
+ * @returns A TestContainer instance.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const testContainer = createTestContainer({
17
+ * overrides: [
18
+ * { token: paymentToken, useValue: fakePaymentService },
19
+ * ],
20
+ * });
21
+ *
22
+ * const service = testContainer.resolve(userToken);
23
+ * expect(service).toBeDefined();
24
+ *
25
+ * await testContainer.dispose();
26
+ * ```
27
+ */
28
+ export function createTestContainer(options = {}) {
29
+ const container = createStartedContainer();
30
+ if (options.overrides) {
31
+ for (const override of options.overrides) {
32
+ container.registerValue(override.token, override.useValue);
33
+ }
34
+ }
35
+ const resolve = (token) => container.resolve(token);
36
+ const has = (token) => container.has(token);
37
+ const dispose = async () => {
38
+ await container.dispose();
39
+ };
40
+ return {
41
+ container,
42
+ resolve,
43
+ has,
44
+ dispose,
45
+ };
46
+ }
47
+ //# sourceMappingURL=testContainer.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testContainer.core.js","sourceRoot":"","sources":["../../src/testContainer/testContainer.core.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAyC3D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAO,GAAyB,EAAE;IAElC,MAAM,SAAS,GAAG,sBAAsB,EAAE,CAAC;IAE3C,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;YACzC,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,CAAI,KAA2B,EAAK,EAAE,CACpD,SAAS,CAAC,OAAO,CAAC,KAAK,CAAM,CAAC;IAEhC,MAAM,GAAG,GAAG,CAAI,KAA2B,EAAW,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAE9E,MAAM,OAAO,GAAG,KAAK,IAAmB,EAAE;QACxC,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC,CAAC;IAEF,OAAO;QACL,SAAS;QACT,OAAO;QACP,GAAG;QACH,OAAO;KACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @zudojs/testing — Central test context.
3
+ *
4
+ * Bundles test utilities into one isolated context per test.
5
+ */
6
+ export { createTestContext } from "./testContext.core.js";
7
+ export type { TestContext, TestContextOptions } from "./testContext.core.js";
8
+ export type { CapturedLogEntry, CapturedEvent, CapturedMessage, LogRecorder, EventRecorder, MessageRecorder, } from "./testContext.recorder.type.js";
9
+ export { createLogRecorder, createEventRecorder, createMessageRecorder, } from "./testContext.recorder.core.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testContext/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE7E,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,WAAW,EACX,aAAa,EACb,eAAe,GAChB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @zudojs/testing — Central test context.
3
+ *
4
+ * Bundles test utilities into one isolated context per test.
5
+ */
6
+ export { createTestContext } from "./testContext.core.js";
7
+ export { createLogRecorder, createEventRecorder, createMessageRecorder, } from "./testContext.recorder.core.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testContext/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAY1D,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @zudojs/testing — Central test context.
3
+ *
4
+ * Provides a single entry point that bundles test utilities
5
+ * for container, logger, config, events, messaging, queue,
6
+ * clock, and cleanup into one isolated context per test.
7
+ */
8
+ import type { CleanupManager } from "../cleanupManager/cleanupManager.core.js";
9
+ import type { TestClock } from "../testClock/testClock.core.js";
10
+ import type { LogRecorder, EventRecorder, MessageRecorder } from "./testContext.recorder.type.js";
11
+ /** Options for creating a test context. */
12
+ export interface TestContextOptions {
13
+ readonly clock?: TestClock;
14
+ readonly cleanup?: CleanupManager;
15
+ }
16
+ /** The central test context bundling all test utilities. */
17
+ export interface TestContext {
18
+ readonly clock: TestClock;
19
+ readonly cleanup: CleanupManager;
20
+ readonly logs: LogRecorder;
21
+ readonly events: EventRecorder;
22
+ readonly messages: MessageRecorder;
23
+ dispose: () => Promise<void>;
24
+ }
25
+ /**
26
+ * Creates an isolated test context with all recording utilities.
27
+ *
28
+ * @param options - Optional configuration.
29
+ * @returns A TestContext instance.
30
+ */
31
+ export declare function createTestContext(options?: TestContextOptions): TestContext;
32
+ //# sourceMappingURL=testContext.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testContext.core.d.ts","sourceRoot":"","sources":["../../src/testContext/testContext.core.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,eAAe,EAChB,MAAM,gCAAgC,CAAC;AAOxC,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;CACnC;AAED,4DAA4D;AAC5D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,kBAAuB,GAC/B,WAAW,CAYb"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @zudojs/testing — Central test context.
3
+ *
4
+ * Provides a single entry point that bundles test utilities
5
+ * for container, logger, config, events, messaging, queue,
6
+ * clock, and cleanup into one isolated context per test.
7
+ */
8
+ import { createCleanupManager } from "../cleanupManager/cleanupManager.core.js";
9
+ import { createTestClock } from "../testClock/testClock.core.js";
10
+ import { createLogRecorder, createEventRecorder, createMessageRecorder, } from "./testContext.recorder.core.js";
11
+ /**
12
+ * Creates an isolated test context with all recording utilities.
13
+ *
14
+ * @param options - Optional configuration.
15
+ * @returns A TestContext instance.
16
+ */
17
+ export function createTestContext(options = {}) {
18
+ const clock = options.clock ?? createTestClock();
19
+ const cleanup = options.cleanup ?? createCleanupManager();
20
+ const logs = createLogRecorder();
21
+ const events = createEventRecorder();
22
+ const messages = createMessageRecorder();
23
+ const dispose = async () => {
24
+ await cleanup.dispose();
25
+ };
26
+ return { clock, cleanup, logs, events, messages, dispose };
27
+ }
28
+ //# sourceMappingURL=testContext.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testContext.core.js","sourceRoot":"","sources":["../../src/testContext/testContext.core.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAQjE,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AAkBxC;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAO,GAAuB,EAAE;IAEhC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,eAAe,EAAE,CAAC;IACjD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,oBAAoB,EAAE,CAAC;IAC1D,MAAM,IAAI,GAAG,iBAAiB,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,mBAAmB,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,qBAAqB,EAAE,CAAC;IAEzC,MAAM,OAAO,GAAG,KAAK,IAAmB,EAAE;QACxC,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @zudojs/testing — Test context recorder implementations.
3
+ *
4
+ * Creates log, event, and message recorders for test contexts.
5
+ */
6
+ import type { LogRecorder, EventRecorder, MessageRecorder } from "./testContext.recorder.type.js";
7
+ /**
8
+ * Creates a log recorder that captures log entries.
9
+ */
10
+ export declare function createLogRecorder(): LogRecorder;
11
+ /**
12
+ * Creates an event recorder that captures events.
13
+ */
14
+ export declare function createEventRecorder(): EventRecorder;
15
+ /**
16
+ * Creates a message recorder that captures messages.
17
+ */
18
+ export declare function createMessageRecorder(): MessageRecorder;
19
+ //# sourceMappingURL=testContext.recorder.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testContext.recorder.core.d.ts","sourceRoot":"","sources":["../../src/testContext/testContext.recorder.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAIV,WAAW,EACX,aAAa,EACb,eAAe,EAChB,MAAM,gCAAgC,CAAC;AAExC;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CA2B/C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,CAoBnD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CAoBvD"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @zudojs/testing — Test context recorder implementations.
3
+ *
4
+ * Creates log, event, and message recorders for test contexts.
5
+ */
6
+ /**
7
+ * Creates a log recorder that captures log entries.
8
+ */
9
+ export function createLogRecorder() {
10
+ const entries = [];
11
+ return {
12
+ get entries() {
13
+ return entries;
14
+ },
15
+ record: (level, message, metadata) => {
16
+ entries.push({
17
+ level,
18
+ message,
19
+ metadata,
20
+ timestamp: new Date(),
21
+ });
22
+ },
23
+ clear: () => {
24
+ entries.length = 0;
25
+ },
26
+ findByLevel: (level) => entries.filter((e) => e.level === level),
27
+ findByMessage: (substring) => entries.filter((e) => e.message.includes(substring)),
28
+ };
29
+ }
30
+ /**
31
+ * Creates an event recorder that captures events.
32
+ */
33
+ export function createEventRecorder() {
34
+ const entries = [];
35
+ return {
36
+ get entries() {
37
+ return entries;
38
+ },
39
+ record: (type, payload) => {
40
+ entries.push({
41
+ type,
42
+ payload,
43
+ timestamp: new Date(),
44
+ });
45
+ },
46
+ clear: () => {
47
+ entries.length = 0;
48
+ },
49
+ findByType: (type) => entries.filter((e) => e.type === type),
50
+ };
51
+ }
52
+ /**
53
+ * Creates a message recorder that captures messages.
54
+ */
55
+ export function createMessageRecorder() {
56
+ const entries = [];
57
+ return {
58
+ get entries() {
59
+ return entries;
60
+ },
61
+ record: (type, payload) => {
62
+ entries.push({
63
+ type,
64
+ payload,
65
+ timestamp: new Date(),
66
+ });
67
+ },
68
+ clear: () => {
69
+ entries.length = 0;
70
+ },
71
+ findByType: (type) => entries.filter((e) => e.type === type),
72
+ };
73
+ }
74
+ //# sourceMappingURL=testContext.recorder.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testContext.recorder.core.js","sourceRoot":"","sources":["../../src/testContext/testContext.recorder.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,OAAO,GAAuB,EAAE,CAAC;IAEvC,OAAO;QACL,IAAI,OAAO;YACT,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,MAAM,EAAE,CACN,KAAa,EACb,OAAe,EACf,QAAkC,EAC5B,EAAE;YACR,OAAO,CAAC,IAAI,CAAC;gBACX,KAAK;gBACL,OAAO;gBACP,QAAQ;gBACR,SAAS,EAAE,IAAI,IAAI,EAAE;aACtB,CAAC,CAAC;QACL,CAAC;QACD,KAAK,EAAE,GAAS,EAAE;YAChB,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QACrB,CAAC;QACD,WAAW,EAAE,CAAC,KAAa,EAA+B,EAAE,CAC1D,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC;QAC1C,aAAa,EAAE,CAAC,SAAiB,EAA+B,EAAE,CAChE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,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 @@
1
+ /**
2
+ * @zudojs/testing — Test context recorder types.
3
+ *
4
+ * Types for log, event, and message recorders used in test contexts.
5
+ */
6
+ /**
7
+ * A captured log entry from a spy logger.
8
+ */
9
+ export interface CapturedLogEntry {
10
+ readonly level: string;
11
+ readonly message: string;
12
+ readonly metadata?: Record<string, unknown>;
13
+ readonly timestamp: Date;
14
+ }
15
+ /**
16
+ * A captured event from a test event bus.
17
+ */
18
+ export interface CapturedEvent {
19
+ readonly type: string;
20
+ readonly payload: unknown;
21
+ readonly timestamp: Date;
22
+ }
23
+ /**
24
+ * A captured message from a test message bus.
25
+ */
26
+ export interface CapturedMessage {
27
+ readonly type: string;
28
+ readonly payload: unknown;
29
+ readonly timestamp: Date;
30
+ }
31
+ /**
32
+ * Records log entries for assertions.
33
+ */
34
+ export interface LogRecorder {
35
+ readonly entries: readonly CapturedLogEntry[];
36
+ record: (level: string, message: string, metadata?: Record<string, unknown>) => void;
37
+ clear: () => void;
38
+ findByLevel: (level: string) => readonly CapturedLogEntry[];
39
+ findByMessage: (substring: string) => readonly CapturedLogEntry[];
40
+ }
41
+ /**
42
+ * Records events for assertions.
43
+ */
44
+ export interface EventRecorder {
45
+ readonly entries: readonly CapturedEvent[];
46
+ record: (type: string, payload: unknown) => void;
47
+ clear: () => void;
48
+ findByType: (type: string) => readonly CapturedEvent[];
49
+ }
50
+ /**
51
+ * Records messages for assertions.
52
+ */
53
+ export interface MessageRecorder {
54
+ readonly entries: readonly CapturedMessage[];
55
+ record: (type: string, payload: unknown) => void;
56
+ clear: () => void;
57
+ findByType: (type: string) => readonly CapturedMessage[];
58
+ }
59
+ //# sourceMappingURL=testContext.recorder.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testContext.recorder.type.d.ts","sourceRoot":"","sources":["../../src/testContext/testContext.recorder.type.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,M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aAAa,EAAE,CAAC;CACxD;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,eAAe,EAAE,CAAC;CAC1D"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @zudojs/testing — Test context recorder types.
3
+ *
4
+ * Types for log, event, and message recorders used in test contexts.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=testContext.recorder.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testContext.recorder.type.js","sourceRoot":"","sources":["../../src/testContext/testContext.recorder.type.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Test event bus helpers.
3
+ *
4
+ * EventBus with recording and assertion support.
5
+ */
6
+ export { createTestEventBus } from "./testEventBus.core.js";
7
+ export type { RecordedEvent, TestEventBus } from "./testEventBus.core.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testEventBus/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Test event bus helpers.
3
+ *
4
+ * EventBus with recording and assertion support.
5
+ */
6
+ export { createTestEventBus } from "./testEventBus.core.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testEventBus/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Test event bus helpers.
3
+ *
4
+ * Wraps the real EventBus with recording and assertion support.
5
+ */
6
+ import { EventBus } from "@zudojs/events";
7
+ import type { Event, EventInput, EventBusOptions, EventPublishResult } from "@zudojs/events";
8
+ /**
9
+ * A recorded event publication.
10
+ */
11
+ export interface RecordedEvent<TPayload = unknown> {
12
+ readonly event: Event<TPayload>;
13
+ readonly result: EventPublishResult<Event<TPayload>>;
14
+ readonly timestamp: Date;
15
+ }
16
+ /**
17
+ * A test event bus with recording capabilities.
18
+ */
19
+ export interface TestEventBus {
20
+ readonly bus: EventBus;
21
+ /**
22
+ * All recorded publications.
23
+ */
24
+ readonly published: readonly RecordedEvent[];
25
+ /**
26
+ * Publish an event and record the result.
27
+ */
28
+ publish: <TPayload>(input: EventInput<TPayload>) => Promise<EventPublishResult<Event<TPayload>>>;
29
+ /**
30
+ * Find published events by type.
31
+ */
32
+ findByType: (type: string) => readonly RecordedEvent[];
33
+ /**
34
+ * Clear recorded publications.
35
+ */
36
+ clear: () => void;
37
+ /**
38
+ * Dispose the event bus.
39
+ */
40
+ dispose: () => void;
41
+ }
42
+ /**
43
+ * Creates a test event bus with recording.
44
+ *
45
+ * @param options - EventBus options.
46
+ * @returns A TestEventBus instance.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const testBus = createTestEventBus();
51
+ *
52
+ * await testBus.publish({ type: "user.created", payload: { id: "123" } });
53
+ *
54
+ * expect(testBus.published).toHaveLength(1);
55
+ * expect(testBus.findByType("user.created")).toHaveLength(1);
56
+ *
57
+ * testBus.dispose();
58
+ * ```
59
+ */
60
+ export declare function createTestEventBus(options?: EventBusOptions): TestEventBus;
61
+ //# sourceMappingURL=testEventBus.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testEventBus.core.d.ts","sourceRoot":"","sources":["../../src/testEventBus/testEventBus.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,EACV,KAAK,EACL,UAAU,EACV,eAAe,EACf,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAIxB;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,QAAQ,GAAG,OAAO;IAC/C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrD,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,SAAS,aAAa,EAAE,CAAC;IAE7C;;OAEG;IACH,OAAO,EAAE,CAAC,QAAQ,EAChB,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,KACxB,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAElD;;OAEG;IACH,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,aAAa,EAAE,CAAC;IAEvD;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAElB;;OAEG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,GAAE,eAAoB,GAC5B,YAAY,CA+Cd"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Test event bus helpers.
3
+ *
4
+ * Wraps the real EventBus with recording and assertion support.
5
+ */
6
+ import { EventBus } from "@zudojs/events";
7
+ /**
8
+ * Creates a test event bus with recording.
9
+ *
10
+ * @param options - EventBus options.
11
+ * @returns A TestEventBus instance.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const testBus = createTestEventBus();
16
+ *
17
+ * await testBus.publish({ type: "user.created", payload: { id: "123" } });
18
+ *
19
+ * expect(testBus.published).toHaveLength(1);
20
+ * expect(testBus.findByType("user.created")).toHaveLength(1);
21
+ *
22
+ * testBus.dispose();
23
+ * ```
24
+ */
25
+ export function createTestEventBus(options = {}) {
26
+ const bus = new EventBus(options);
27
+ const published = [];
28
+ bus.start();
29
+ const publish = async (input) => {
30
+ const event = {
31
+ id: `evt_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
32
+ type: input.type,
33
+ payload: input.payload,
34
+ timestamp: new Date(),
35
+ ...(input.metadata ? { metadata: input.metadata } : {}),
36
+ };
37
+ const result = await bus.publish(event);
38
+ published.push({
39
+ event: result.event,
40
+ result,
41
+ timestamp: new Date(),
42
+ });
43
+ return result;
44
+ };
45
+ const findByType = (type) => published.filter((e) => e.event.type === type);
46
+ const clear = () => {
47
+ published.length = 0;
48
+ };
49
+ const dispose = () => {
50
+ bus.dispose();
51
+ };
52
+ return {
53
+ bus,
54
+ published,
55
+ publish,
56
+ findByType,
57
+ clear,
58
+ dispose,
59
+ };
60
+ }
61
+ //# sourceMappingURL=testEventBus.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testEventBus.core.js","sourceRoot":"","sources":["../../src/testEventBus/testEventBus.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAsD1C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAO,GAAoB,EAAE;IAE7B,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,SAAS,GAAoB,EAAE,CAAC;IAEtC,GAAG,CAAC,KAAK,EAAE,CAAC;IAEZ,MAAM,OAAO,GAAG,KAAK,EACnB,KAA2B,EACmB,EAAE;QAChD,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"./testMessageBus.core.js";
7
+ export type { RecordedMessage, TestMessageBus } from "./testMessageBus.core.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testMessageBus/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Test message bus helpers.
3
+ *
4
+ * MessageBus with recording and assertion support.
5
+ */
6
+ export { createTestMessageBus } from "./testMessageBus.core.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testMessageBus/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Test message bus helpers.
3
+ *
4
+ * Wraps the real MessageBus with recording and assertion support.
5
+ */
6
+ import type { Message, MessageInput, MessageBus, MessageBusOptions, DispatchResult, DispatchOptions } from "@zudojs/messaging";
7
+ /**
8
+ * A recorded message dispatch.
9
+ */
10
+ export interface RecordedMessage<TPayload = unknown> {
11
+ readonly message: Message<TPayload>;
12
+ readonly result: DispatchResult;
13
+ readonly timestamp: Date;
14
+ }
15
+ /**
16
+ * A test message bus with recording capabilities.
17
+ */
18
+ export interface TestMessageBus {
19
+ readonly bus: MessageBus;
20
+ /**
21
+ * All recorded dispatches.
22
+ */
23
+ readonly dispatched: readonly RecordedMessage[];
24
+ /**
25
+ * Send a message and record the result.
26
+ */
27
+ send: <TPayload>(input: MessageInput<TPayload>, options?: DispatchOptions) => Promise<DispatchResult>;
28
+ /**
29
+ * Find dispatched messages by type.
30
+ */
31
+ findByType: (type: string) => readonly RecordedMessage[];
32
+ /**
33
+ * Clear recorded dispatches.
34
+ */
35
+ clear: () => void;
36
+ /**
37
+ * Dispose the message bus.
38
+ */
39
+ dispose: () => void;
40
+ }
41
+ /**
42
+ * Creates a test message bus with recording.
43
+ *
44
+ * @param options - MessageBus options.
45
+ * @returns A TestMessageBus instance.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const testBus = createTestMessageBus();
50
+ *
51
+ * testBus.bus.on("user.created", handler);
52
+ * await testBus.send({ type: "user.created", payload: { id: "123" } });
53
+ *
54
+ * expect(testBus.dispatched).toHaveLength(1);
55
+ * expect(testBus.findByType("user.created")).toHaveLength(1);
56
+ *
57
+ * testBus.dispose();
58
+ * ```
59
+ */
60
+ export declare function createTestMessageBus(options?: MessageBusOptions): TestMessageBus;
61
+ //# sourceMappingURL=testMessageBus.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testMessageBus.core.d.ts","sourceRoot":"","sources":["../../src/testMessageBus/testMessageBus.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,UAAU,EACV,iBAAiB,EAEjB,cAAc,EACd,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,QAAQ,GAAG,OAAO;IACjD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,eAAe,EAAE,CAAC;IAEhD;;OAEG;IACH,IAAI,EAAE,CAAC,QAAQ,EACb,KAAK,EAAE,YAAY,CAAC,QAAQ,CAAC,EAC7B,OAAO,CAAC,EAAE,eAAe,KACtB,OAAO,CAAC,cAAc,CAAC,CAAC;IAE7B;;OAEG;IACH,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,eAAe,EAAE,CAAC;IAEzD;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAElB;;OAEG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,iBAAsB,GAC9B,cAAc,CA8ChB"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Test message bus helpers.
3
+ *
4
+ * Wraps the real MessageBus with recording and assertion support.
5
+ */
6
+ import { createMessageBus } from "@zudojs/messaging";
7
+ /**
8
+ * Creates a test message bus with recording.
9
+ *
10
+ * @param options - MessageBus options.
11
+ * @returns A TestMessageBus instance.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const testBus = createTestMessageBus();
16
+ *
17
+ * testBus.bus.on("user.created", handler);
18
+ * await testBus.send({ type: "user.created", payload: { id: "123" } });
19
+ *
20
+ * expect(testBus.dispatched).toHaveLength(1);
21
+ * expect(testBus.findByType("user.created")).toHaveLength(1);
22
+ *
23
+ * testBus.dispose();
24
+ * ```
25
+ */
26
+ export function createTestMessageBus(options = {}) {
27
+ const bus = createMessageBus(options);
28
+ const dispatched = [];
29
+ const send = async (input, dispatchOptions) => {
30
+ const message = {
31
+ id: `msg_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
32
+ type: input.type,
33
+ payload: input.payload,
34
+ timestamp: new Date(),
35
+ ...(input.metadata ? { metadata: input.metadata } : {}),
36
+ };
37
+ const result = await bus.send(message, dispatchOptions);
38
+ dispatched.push({
39
+ message,
40
+ result,
41
+ timestamp: new Date(),
42
+ });
43
+ return result;
44
+ };
45
+ const findByType = (type) => dispatched.filter((d) => d.message.type === type);
46
+ const clear = () => {
47
+ dispatched.length = 0;
48
+ };
49
+ const dispose = () => {
50
+ bus.dispose();
51
+ };
52
+ return {
53
+ bus,
54
+ dispatched,
55
+ send,
56
+ findByType,
57
+ clear,
58
+ dispose,
59
+ };
60
+ }
61
+ //# sourceMappingURL=testMessageBus.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testMessageBus.core.js","sourceRoot":"","sources":["../../src/testMessageBus/testMessageBus.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAwDrD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAO,GAAsB,EAAE;IAE/B,MAAM,GAAG,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,UAAU,GAAsB,EAAE,CAAC;IAEzC,MAAM,IAAI,GAAG,KAAK,EAChB,KAA6B,EAC7B,eAAiC,EACR,EAAE;QAC3B,MAAM,OAAO,GAAsB;YACjC,EAAE,EAAE,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAe;YAC9E,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACxD,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QAExD,UAAU,CAAC,IAAI,CAAC;YACd,OAAO;YACP,MAAM;YACN,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,MAAM,UAA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