@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,59 @@
1
+ /**
2
+ * Event fixtures for testing.
3
+ *
4
+ * Factory functions for creating test event payloads.
5
+ */
6
+ let eventCounter = 0;
7
+ /**
8
+ * Creates a test event.
9
+ *
10
+ * @param options - Event options.
11
+ * @returns A test Event instance.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const event = createEvent<{ userId: string }>({
16
+ * type: "user.created",
17
+ * payload: { userId: "123" },
18
+ * });
19
+ *
20
+ * expect(event.type).toBe("user.created");
21
+ * expect(event.payload).toEqual({ userId: "123" });
22
+ * ```
23
+ */
24
+ export function createEvent(options = {}) {
25
+ eventCounter++;
26
+ return {
27
+ id: options.id ?? `evt_${Date.now()}_${eventCounter}`,
28
+ type: options.type ?? "test.event",
29
+ payload: options.payload ?? {},
30
+ timestamp: options.timestamp ?? new Date(),
31
+ ...(options.metadata ? { metadata: options.metadata } : {}),
32
+ };
33
+ }
34
+ /**
35
+ * Creates a test event input.
36
+ *
37
+ * @param type - Event type.
38
+ * @param payload - Event payload.
39
+ * @param metadata - Optional metadata.
40
+ * @returns An EventInput instance.
41
+ */
42
+ export function createEventInput(type, payload, metadata) {
43
+ return {
44
+ type,
45
+ payload,
46
+ ...(metadata ? { metadata } : {}),
47
+ };
48
+ }
49
+ /**
50
+ * Creates multiple test events.
51
+ *
52
+ * @param count - Number of events to create.
53
+ * @param factory - Factory function for each event.
54
+ * @returns Array of test Events.
55
+ */
56
+ export function createEvents(count, factory) {
57
+ return Array.from({ length: count }, (_, i) => createEvent(factory(i)));
58
+ }
59
+ //# sourceMappingURL=eventFixtures.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventFixtures.core.js","sourceRoot":"","sources":["../../src/fixtures/eventFixtures.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,WAAW,CACzB,OAAO,GAAiC,EAAE;IAE1C,YAAY,EAAE,CAAC;IAEf,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE,IAAK,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,YAAY,EAAc;QAClE,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,YAAY;QAClC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAK,EAAe;QAC5C,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE;QAC1C,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5D,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,OAAiB,EACjB,QAAkC;IAElC,OAAO;QACL,IAAI;QACJ,OAAO;QACP,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAa,EACb,OAAwD;IAExD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Test fixtures.
3
+ *
4
+ * Factory functions for creating test data.
5
+ */
6
+ export { createEvent, createEventInput, createEvents, } from "./eventFixtures.core.js";
7
+ export { createMessage, createMessageInput, createMessages, } from "./messageFixtures.core.js";
8
+ export type { CreateEventOptions } from "./eventFixtures.core.js";
9
+ export type { CreateMessageOptions } from "./messageFixtures.core.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fixtures/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,YAAY,GACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,cAAc,GACf,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Test fixtures.
3
+ *
4
+ * Factory functions for creating test data.
5
+ */
6
+ export { createEvent, createEventInput, createEvents, } from "./eventFixtures.core.js";
7
+ export { createMessage, createMessageInput, createMessages, } from "./messageFixtures.core.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fixtures/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,YAAY,GACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,cAAc,GACf,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Message fixtures for testing.
3
+ *
4
+ * Factory functions for creating test message payloads.
5
+ */
6
+ import type { Message, MessageInput } from "@zudojs/messaging";
7
+ import type { MessageId } from "@zudojs/messaging";
8
+ /**
9
+ * Options for creating a test message.
10
+ */
11
+ export interface CreateMessageOptions<TPayload> {
12
+ readonly type?: string;
13
+ readonly payload?: TPayload;
14
+ readonly id?: MessageId;
15
+ readonly timestamp?: Date;
16
+ readonly metadata?: Record<string, unknown>;
17
+ }
18
+ /**
19
+ * Creates a test message.
20
+ *
21
+ * @param options - Message options.
22
+ * @returns A test Message instance.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const message = createMessage<{ userId: string }>({
27
+ * type: "user.created",
28
+ * payload: { userId: "123" },
29
+ * });
30
+ *
31
+ * expect(message.type).toBe("user.created");
32
+ * expect(message.payload).toEqual({ userId: "123" });
33
+ * ```
34
+ */
35
+ export declare function createMessage<TPayload = unknown>(options?: CreateMessageOptions<TPayload>): Message<TPayload>;
36
+ /**
37
+ * Creates a test message input.
38
+ *
39
+ * @param type - Message type.
40
+ * @param payload - Message payload.
41
+ * @param metadata - Optional metadata.
42
+ * @returns A MessageInput instance.
43
+ */
44
+ export declare function createMessageInput<TPayload>(type: string, payload: TPayload, metadata?: Record<string, unknown>): MessageInput<TPayload>;
45
+ /**
46
+ * Creates multiple test messages.
47
+ *
48
+ * @param count - Number of messages to create.
49
+ * @param factory - Factory function for each message.
50
+ * @returns Array of test Messages.
51
+ */
52
+ export declare function createMessages<TPayload>(count: number, factory: (index: number) => CreateMessageOptions<TPayload>): Message<TPayload>[];
53
+ //# sourceMappingURL=messageFixtures.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageFixtures.core.d.ts","sourceRoot":"","sources":["../../src/fixtures/messageFixtures.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,QAAQ;IAC5C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC;IACxB,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,aAAa,CAAC,QAAQ,GAAG,OAAO,EAC9C,OAAO,GAAE,oBAAoB,CAAC,QAAQ,CAAM,GAC3C,OAAO,CAAC,QAAQ,CAAC,CAUnB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EACzC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,QAAQ,EACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,YAAY,CAAC,QAAQ,CAAC,CAMxB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EACrC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,oBAAoB,CAAC,QAAQ,CAAC,GACzD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAErB"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Message fixtures for testing.
3
+ *
4
+ * Factory functions for creating test message payloads.
5
+ */
6
+ let messageCounter = 0;
7
+ /**
8
+ * Creates a test message.
9
+ *
10
+ * @param options - Message options.
11
+ * @returns A test Message instance.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const message = createMessage<{ userId: string }>({
16
+ * type: "user.created",
17
+ * payload: { userId: "123" },
18
+ * });
19
+ *
20
+ * expect(message.type).toBe("user.created");
21
+ * expect(message.payload).toEqual({ userId: "123" });
22
+ * ```
23
+ */
24
+ export function createMessage(options = {}) {
25
+ messageCounter++;
26
+ return {
27
+ id: options.id ?? `msg_${Date.now()}_${messageCounter}`,
28
+ type: options.type ?? "test.message",
29
+ payload: options.payload ?? {},
30
+ timestamp: options.timestamp ?? new Date(),
31
+ ...(options.metadata ? { metadata: options.metadata } : {}),
32
+ };
33
+ }
34
+ /**
35
+ * Creates a test message input.
36
+ *
37
+ * @param type - Message type.
38
+ * @param payload - Message payload.
39
+ * @param metadata - Optional metadata.
40
+ * @returns A MessageInput instance.
41
+ */
42
+ export function createMessageInput(type, payload, metadata) {
43
+ return {
44
+ type,
45
+ payload,
46
+ ...(metadata ? { metadata } : {}),
47
+ };
48
+ }
49
+ /**
50
+ * Creates multiple test messages.
51
+ *
52
+ * @param count - Number of messages to create.
53
+ * @param factory - Factory function for each message.
54
+ * @returns Array of test Messages.
55
+ */
56
+ export function createMessages(count, factory) {
57
+ return Array.from({ length: count }, (_, i) => createMessage(factory(i)));
58
+ }
59
+ //# sourceMappingURL=messageFixtures.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageFixtures.core.js","sourceRoot":"","sources":["../../src/fixtures/messageFixtures.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,IAAI,cAAc,GAAG,CAAC,CAAC;AAEvB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAO,GAAmC,EAAE;IAE5C,cAAc,EAAE,CAAC;IAEjB,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE,IAAK,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,cAAc,EAAgB;QACtE,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,cAAc;QACpC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAK,EAAe;QAC5C,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE;QAC1C,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5D,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAY,EACZ,OAAiB,EACjB,QAAkC;IAElC,OAAO;QACL,IAAI;QACJ,OAAO;QACP,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAa,EACb,OAA0D;IAE1D,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * HTTP request builder for testing.
3
+ *
4
+ * Provides a fluent API for constructing test HTTP requests.
5
+ */
6
+ /** HTTP method type. */
7
+ export type HTTPMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
8
+ /**
9
+ * A test HTTP request.
10
+ */
11
+ export interface TestHTTPRequest {
12
+ readonly method: HTTPMethod;
13
+ readonly path: string;
14
+ readonly headers: Headers;
15
+ readonly query: Record<string, string>;
16
+ readonly body: unknown;
17
+ readonly params: Record<string, string>;
18
+ }
19
+ /**
20
+ * Fluent builder for test HTTP requests.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const request = createTestHTTPRequest()
25
+ * .GET("/api/users")
26
+ * .withHeader("Authorization", "Bearer token123")
27
+ * .withQuery({ page: "1", limit: "10" })
28
+ * .build();
29
+ *
30
+ * expect(request.method).toBe("GET");
31
+ * expect(request.path).toBe("/api/users");
32
+ * ```
33
+ */
34
+ export interface HTTPRequestBuilder {
35
+ GET: (path: string) => HTTPRequestBuilder;
36
+ POST: (path: string) => HTTPRequestBuilder;
37
+ PUT: (path: string) => HTTPRequestBuilder;
38
+ PATCH: (path: string) => HTTPRequestBuilder;
39
+ DELETE: (path: string) => HTTPRequestBuilder;
40
+ HEAD: (path: string) => HTTPRequestBuilder;
41
+ OPTIONS: (path: string) => HTTPRequestBuilder;
42
+ withHeader: (key: string, value: string) => HTTPRequestBuilder;
43
+ withHeaders: (headers: Headers | Record<string, string>) => HTTPRequestBuilder;
44
+ withQuery: (query: Record<string, string>) => HTTPRequestBuilder;
45
+ withParam: (key: string, value: string) => HTTPRequestBuilder;
46
+ withBody: (body: unknown) => HTTPRequestBuilder;
47
+ build: () => TestHTTPRequest;
48
+ }
49
+ /**
50
+ * Creates a new HTTP request builder.
51
+ *
52
+ * @returns An HTTPRequestBuilder instance.
53
+ */
54
+ export declare function createTestHTTPRequest(): HTTPRequestBuilder;
55
+ /**
56
+ * Creates a simple test HTTP request without the builder pattern.
57
+ *
58
+ * @param method - HTTP method.
59
+ * @param path - Request path.
60
+ * @param options - Optional headers, query, and body.
61
+ * @returns A TestHTTPRequest instance.
62
+ */
63
+ export declare function createHTTPRequest(method: HTTPMethod, path: string, options?: {
64
+ readonly headers?: Headers | Record<string, string>;
65
+ readonly query?: Record<string, string>;
66
+ readonly body?: unknown;
67
+ readonly params?: Record<string, string>;
68
+ }): TestHTTPRequest;
69
+ //# sourceMappingURL=httpRequest.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpRequest.core.d.ts","sourceRoot":"","sources":["../../src/httpTesting/httpRequest.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAwB;AACxB,MAAM,MAAM,UAAU,GACpB,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAA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AC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC,GACL,eAAe,CASjB"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * HTTP request builder for testing.
3
+ *
4
+ * Provides a fluent API for constructing test HTTP requests.
5
+ */
6
+ /**
7
+ * Creates a new HTTP request builder.
8
+ *
9
+ * @returns An HTTPRequestBuilder instance.
10
+ */
11
+ export function createTestHTTPRequest() {
12
+ let method = "GET";
13
+ let path = "/";
14
+ const headers = new Headers();
15
+ const query = {};
16
+ const params = {};
17
+ let body = undefined;
18
+ const builder = {
19
+ GET: (p) => {
20
+ method = "GET";
21
+ path = p;
22
+ return builder;
23
+ },
24
+ POST: (p) => {
25
+ method = "POST";
26
+ path = p;
27
+ return builder;
28
+ },
29
+ PUT: (p) => {
30
+ method = "PUT";
31
+ path = p;
32
+ return builder;
33
+ },
34
+ PATCH: (p) => {
35
+ method = "PATCH";
36
+ path = p;
37
+ return builder;
38
+ },
39
+ DELETE: (p) => {
40
+ method = "DELETE";
41
+ path = p;
42
+ return builder;
43
+ },
44
+ HEAD: (p) => {
45
+ method = "HEAD";
46
+ path = p;
47
+ return builder;
48
+ },
49
+ OPTIONS: (p) => {
50
+ method = "OPTIONS";
51
+ path = p;
52
+ return builder;
53
+ },
54
+ withHeader: (key, value) => {
55
+ headers.set(key.toLowerCase(), value);
56
+ return builder;
57
+ },
58
+ withHeaders: (h) => {
59
+ if (h instanceof Headers) {
60
+ h.forEach((value, key) => {
61
+ headers.set(key, value);
62
+ });
63
+ }
64
+ else {
65
+ for (const [key, value] of Object.entries(h)) {
66
+ headers.set(key.toLowerCase(), value);
67
+ }
68
+ }
69
+ return builder;
70
+ },
71
+ withQuery: (q) => {
72
+ for (const [key, value] of Object.entries(q)) {
73
+ query[key] = value;
74
+ }
75
+ return builder;
76
+ },
77
+ withParam: (key, value) => {
78
+ params[key] = value;
79
+ return builder;
80
+ },
81
+ withBody: (b) => {
82
+ body = b;
83
+ return builder;
84
+ },
85
+ build: () => ({
86
+ method,
87
+ path,
88
+ headers: new Headers(headers),
89
+ query: { ...query },
90
+ body,
91
+ params: { ...params },
92
+ }),
93
+ };
94
+ return builder;
95
+ }
96
+ /**
97
+ * Creates a simple test HTTP request without the builder pattern.
98
+ *
99
+ * @param method - HTTP method.
100
+ * @param path - Request path.
101
+ * @param options - Optional headers, query, and body.
102
+ * @returns A TestHTTPRequest instance.
103
+ */
104
+ export function createHTTPRequest(method, path, options = {}) {
105
+ return {
106
+ method,
107
+ path,
108
+ headers: new Headers(options.headers),
109
+ query: options.query ?? {},
110
+ body: options.body,
111
+ params: options.params ?? {},
112
+ };
113
+ }
114
+ //# sourceMappingURL=httpRequest.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpRequest.core.js","sourceRoot":"","sources":["../../src/httpTesting/httpRequest.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmDH;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,MAAM,GAAe,KAAK,CAAC;IAC/B,IAAI,IAAI,GAAG,GAAG,CAAC;IACf,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,MAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,IAAI,IAAI,GAAY,SAAS,CAAC;IAE9B,MAAM,OAAO,GAAuB;QAClC,GAAG,EAAE,CAAC,CAAS,EAAE,EAAE;YACjB,MAAM,GAAG,KAAK,CAAC;YACf,IAAI,GAAG,CAAC,CAAC;YACT,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,IAAI,EAAE,CAAC,CAAS,EAAE,EAAE;YAClB,MAAM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AAI;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;KAC7B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @zudojs/testing — HTTP response builder for testing.
3
+ *
4
+ * Provides a fluent API for constructing test HTTP responses.
5
+ */
6
+ import type { HTTPResponseBuilder } from "./httpResponse.type.js";
7
+ /**
8
+ * Creates a new HTTP response builder.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const response = createTestHTTPResponse()
13
+ * .status(200)
14
+ * .header("Content-Type", "application/json")
15
+ * .json({ id: "123", name: "John" })
16
+ * .build();
17
+ * ```
18
+ */
19
+ export declare function createTestHTTPResponse(): HTTPResponseBuilder;
20
+ //# sourceMappingURL=httpResponse.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpResponse.core.d.ts","sourceRoot":"","sources":["../../src/httpTesting/httpResponse.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAEV,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,IAAI,mBAAmB,CA2D5D"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @zudojs/testing — HTTP response builder for testing.
3
+ *
4
+ * Provides a fluent API for constructing test HTTP responses.
5
+ */
6
+ /**
7
+ * Creates a new HTTP response builder.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const response = createTestHTTPResponse()
12
+ * .status(200)
13
+ * .header("Content-Type", "application/json")
14
+ * .json({ id: "123", name: "John" })
15
+ * .build();
16
+ * ```
17
+ */
18
+ export function createTestHTTPResponse() {
19
+ let status = 200;
20
+ const responseHeaders = new Headers();
21
+ let body = undefined;
22
+ let sent = false;
23
+ const builder = {
24
+ status: (code) => {
25
+ status = code;
26
+ return builder;
27
+ },
28
+ header: (key, value) => {
29
+ responseHeaders.set(key.toLowerCase(), value);
30
+ return builder;
31
+ },
32
+ headers: (h) => {
33
+ if (h instanceof Headers) {
34
+ h.forEach((value, key) => {
35
+ responseHeaders.set(key, value);
36
+ });
37
+ }
38
+ else {
39
+ for (const [key, value] of Object.entries(h)) {
40
+ responseHeaders.set(key.toLowerCase(), value);
41
+ }
42
+ }
43
+ return builder;
44
+ },
45
+ json: (b) => {
46
+ body = b;
47
+ responseHeaders.set("content-type", "application/json");
48
+ sent = true;
49
+ return builder;
50
+ },
51
+ text: (b) => {
52
+ body = b;
53
+ responseHeaders.set("content-type", "text/plain");
54
+ sent = true;
55
+ return builder;
56
+ },
57
+ html: (b) => {
58
+ body = b;
59
+ responseHeaders.set("content-type", "text/html");
60
+ sent = true;
61
+ return builder;
62
+ },
63
+ empty: () => {
64
+ body = undefined;
65
+ sent = true;
66
+ return builder;
67
+ },
68
+ build: () => ({
69
+ status,
70
+ headers: new Headers(responseHeaders),
71
+ body,
72
+ sent,
73
+ }),
74
+ };
75
+ return builder;
76
+ }
77
+ //# sourceMappingURL=httpResponse.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpResponse.core.js","sourceRoot":"","sources":["../../src/httpTesting/httpResponse.core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB;IACpC,IAAI,MAAM,GAAmB,GAAG,CAAC;IACjC,MAAM,eAAe,GAAG,IAAI,OAAO,EAAE,CAAC;IACtC,IAAI,IAAI,GAAY,SAAS,CAAC;IAC9B,IAAI,IAAI,GAAG,KAAK,CAAC;IAEjB,MAAM,OAAO,GAAwB;QACnC,MAAM,EAAE,CAAC,IAAoB,EAAE,EAAE;YAC/B,MAAM,GAAG,IAAI,CAAC;YACd,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,MAAM,EAAE,CAAC,GAAW,EAAE,KAAa,EAAE,EAAE;YACrC,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC;YAC9C,OAAO,OAAO,CAAC;QACj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,KAAK,EAAE,GAAqB,EAAE,CAAC,CAAC;YAC9B,MAAM;YACN,OAAO,EAAE,IAAI,OAAO,CAAC,eAAe,CAAC;YACrC,IAAI;YACJ,IAAI;SACL,CAAC;KACH,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @zudojs/testing — HTTP response helper functions.
3
+ *
4
+ * Convenience functions for creating common test HTTP responses.
5
+ */
6
+ import type { HTTPStatusCode } from "./httpStatusCode.type.js";
7
+ import type { TestHTTPResponse } from "./httpResponse.type.js";
8
+ /**
9
+ * Creates a simple test HTTP response without the builder pattern.
10
+ */
11
+ export declare function createHTTPResponse(status: HTTPStatusCode, body?: unknown, headers?: Headers | Record<string, string>): TestHTTPResponse;
12
+ /** Creates a 200 OK JSON response. */
13
+ export declare function jsonResponse(body: unknown): TestHTTPResponse;
14
+ /** Creates a 201 Created JSON response. */
15
+ export declare function createdResponse(body: unknown): TestHTTPResponse;
16
+ /** Creates a 204 No Content response. */
17
+ export declare function noContentResponse(): TestHTTPResponse;
18
+ /** Creates a 400 Bad Request response. */
19
+ export declare function badRequestResponse(message: string): TestHTTPResponse;
20
+ /** Creates a 404 Not Found response. */
21
+ export declare function notFoundResponse(message?: string): TestHTTPResponse;
22
+ /** Creates a 500 Internal Server Error response. */
23
+ export declare function serverErrorResponse(message?: string): TestHTTPResponse;
24
+ //# sourceMappingURL=httpResponse.helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpResponse.helpers.d.ts","sourceRoot":"","sources":["../../src/httpTesting/httpResponse.helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,cAAc,EACtB,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACzC,gBAAgB,CAOlB;AAED,sCAAsC;AACtC,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAE5D;AAED,2CAA2C;AAC3C,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAE/D;AAED,yCAAyC;AACzC,wBAAgB,iBAAiB,IAAI,gBAAgB,CAEpD;AAED,0CAA0C;AAC1C,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAMpE;AAED,wCAAwC;AACxC,wBAAgB,gBAAgB,CAAC,OAAO,SAAc,GAAG,gBAAgB,CAMxE;AAED,oDAAoD;AACpD,wBAAgB,mBAAmB,CACjC,OAAO,SAA0B,GAChC,gBAAgB,CAMlB"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @zudojs/testing — HTTP response helper functions.
3
+ *
4
+ * Convenience functions for creating common test HTTP responses.
5
+ */
6
+ /**
7
+ * Creates a simple test HTTP response without the builder pattern.
8
+ */
9
+ export function createHTTPResponse(status, body, headers) {
10
+ return {
11
+ status,
12
+ headers: new Headers(headers),
13
+ body,
14
+ sent: true,
15
+ };
16
+ }
17
+ /** Creates a 200 OK JSON response. */
18
+ export function jsonResponse(body) {
19
+ return createHTTPResponse(200, body, { "content-type": "application/json" });
20
+ }
21
+ /** Creates a 201 Created JSON response. */
22
+ export function createdResponse(body) {
23
+ return createHTTPResponse(201, body, { "content-type": "application/json" });
24
+ }
25
+ /** Creates a 204 No Content response. */
26
+ export function noContentResponse() {
27
+ return createHTTPResponse(204);
28
+ }
29
+ /** Creates a 400 Bad Request response. */
30
+ export function badRequestResponse(message) {
31
+ return createHTTPResponse(400, { error: message }, { "content-type": "application/json" });
32
+ }
33
+ /** Creates a 404 Not Found response. */
34
+ export function notFoundResponse(message = "Not Found") {
35
+ return createHTTPResponse(404, { error: message }, { "content-type": "application/json" });
36
+ }
37
+ /** Creates a 500 Internal Server Error response. */
38
+ export function serverErrorResponse(message = "Internal Server Error") {
39
+ return createHTTPResponse(500, { error: message }, { "content-type": "application/json" });
40
+ }
41
+ //# sourceMappingURL=httpResponse.helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpResponse.helpers.js","sourceRoot":"","sources":["../../src/httpTesting/httpResponse.helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAAsB,EACtB,IAAc,EACd,OAA0C;IAE1C,OAAO;QACL,MAAM;QACN,OAAO,EAAE,IAAI,OAAO,CAAC,OAAiC,CAAC;QACvD,IAAI;QACJ,IAAI,EAAE,IAAI;KACX,CAAC;AACJ,CAAC;AAED,sCAAsC;AACtC,MAAM,UAAU,YAAY,CAAC,IAAa;IACxC,OAAO,kBAAkB,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,eAAe,CAAC,IAAa;IAC3C,OAAO,kBAAkB,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED,yCAAyC;AACzC,MAAM,UAAU,iBAAiB;IAC/B,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,OAAO,kBAAkB,CACvB,GAAG,EACH,EAAE,KAAK,EAAE,OAAO,EAAE,EAClB,EAAE,cAAc,EAAE,kBAAkB,EAAE,CACvC,CAAC;AACJ,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,gBAAgB,CAAC,OAAO,GAAG,WAAW;IACpD,OAAO,kBAAkB,CACvB,GAAG,EACH,EAAE,KAAK,EAAE,OAAO,EAAE,EAClB,EAAE,cAAc,EAAE,kBAAkB,EAAE,CACvC,CAAC;AACJ,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,mBAAmB,CACjC,OAAO,GAAG,uBAAuB;IAEjC,OAAO,kBAAkB,CACvB,GAAG,EACH,EAAE,KAAK,EAAE,OAAO,EAAE,EAClB,EAAE,cAAc,EAAE,kBAAkB,EAAE,CACvC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @zudojs/testing — HTTP response types.
3
+ *
4
+ * Types for test HTTP responses and response builders.
5
+ */
6
+ import type { HTTPStatusCode } from "./httpStatusCode.type.js";
7
+ /** A test HTTP response. */
8
+ export interface TestHTTPResponse {
9
+ readonly status: HTTPStatusCode;
10
+ readonly headers: Headers;
11
+ readonly body: unknown;
12
+ readonly sent: boolean;
13
+ }
14
+ /** Fluent builder for test HTTP responses. */
15
+ export interface HTTPResponseBuilder {
16
+ status: (code: HTTPStatusCode) => HTTPResponseBuilder;
17
+ header: (key: string, value: string) => HTTPResponseBuilder;
18
+ headers: (headers: Headers | Record<string, string>) => HTTPResponseBuilder;
19
+ json: (body: unknown) => HTTPResponseBuilder;
20
+ text: (body: string) => HTTPResponseBuilder;
21
+ html: (body: string) => HTTPResponseBuilder;
22
+ empty: () => HTTPResponseBuilder;
23
+ build: () => TestHTTPResponse;
24
+ }
25
+ //# sourceMappingURL=httpResponse.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpResponse.type.d.ts","sourceRoot":"","sources":["../../src/httpTesting/httpResponse.type.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,4BAA4B;AAC5B,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAED,8CAA8C;AAC9C,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,mBAAmB,CAAC;IACtD,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,mBAAmB,CAAC;IAC5D,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,mBAAmB,CAAC;IAC5E,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,mBAAmB,CAAC;IAC7C,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,mBAAmB,CAAC;IAC5C,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,mBAAmB,CAAC;IAC5C,KAAK,EAAE,MAAM,mBAAmB,CAAC;IACjC,KAAK,EAAE,MAAM,gBAAgB,CAAC;CAC/B"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @zudojs/testing — HTTP response types.
3
+ *
4
+ * Types for test HTTP responses and response builders.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=httpResponse.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpResponse.type.js","sourceRoot":"","sources":["../../src/httpTesting/httpResponse.type.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @zudojs/testing — HTTP status code type.
3
+ *
4
+ * Local definition of HTTPStatusCode for testing purposes.
5
+ * When @zudojs/http builds cleanly, this should be replaced
6
+ * with an import from @zudojs/http.
7
+ */
8
+ /** HTTP status code number. */
9
+ export type HTTPStatusCode = number;
10
+ //# sourceMappingURL=httpStatusCode.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpStatusCode.type.d.ts","sourceRoot":"","sources":["../../src/httpTesting/httpStatusCode.type.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,+BAA+B;AAC/B,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC"}