@stratal/testing 0.0.1 → 0.0.2

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 (87) hide show
  1. package/README.md +332 -0
  2. package/package.json +10 -10
  3. package/dist/core/env/index.d.ts +0 -2
  4. package/dist/core/env/index.d.ts.map +0 -1
  5. package/dist/core/env/index.js +0 -2
  6. package/dist/core/env/index.js.map +0 -1
  7. package/dist/core/env/test-env.d.ts +0 -9
  8. package/dist/core/env/test-env.d.ts.map +0 -1
  9. package/dist/core/env/test-env.js +0 -14
  10. package/dist/core/env/test-env.js.map +0 -1
  11. package/dist/core/http/fetch-mock.d.ts +0 -236
  12. package/dist/core/http/fetch-mock.d.ts.map +0 -1
  13. package/dist/core/http/fetch-mock.js +0 -290
  14. package/dist/core/http/fetch-mock.js.map +0 -1
  15. package/dist/core/http/fetch-mock.types.d.ts +0 -48
  16. package/dist/core/http/fetch-mock.types.d.ts.map +0 -1
  17. package/dist/core/http/fetch-mock.types.js +0 -2
  18. package/dist/core/http/fetch-mock.types.js.map +0 -1
  19. package/dist/core/http/index.d.ts +0 -6
  20. package/dist/core/http/index.d.ts.map +0 -1
  21. package/dist/core/http/index.js +0 -5
  22. package/dist/core/http/index.js.map +0 -1
  23. package/dist/core/http/test-http-client.d.ts +0 -54
  24. package/dist/core/http/test-http-client.d.ts.map +0 -1
  25. package/dist/core/http/test-http-client.js +0 -75
  26. package/dist/core/http/test-http-client.js.map +0 -1
  27. package/dist/core/http/test-http-request.d.ts +0 -44
  28. package/dist/core/http/test-http-request.d.ts.map +0 -1
  29. package/dist/core/http/test-http-request.js +0 -75
  30. package/dist/core/http/test-http-request.js.map +0 -1
  31. package/dist/core/http/test-response.d.ts +0 -161
  32. package/dist/core/http/test-response.d.ts.map +0 -1
  33. package/dist/core/http/test-response.js +0 -309
  34. package/dist/core/http/test-response.js.map +0 -1
  35. package/dist/core/index.d.ts +0 -7
  36. package/dist/core/index.d.ts.map +0 -1
  37. package/dist/core/index.js +0 -7
  38. package/dist/core/index.js.map +0 -1
  39. package/dist/core/override/index.d.ts +0 -2
  40. package/dist/core/override/index.d.ts.map +0 -1
  41. package/dist/core/override/index.js +0 -2
  42. package/dist/core/override/index.js.map +0 -1
  43. package/dist/core/override/provider-override-builder.d.ts +0 -77
  44. package/dist/core/override/provider-override-builder.d.ts.map +0 -1
  45. package/dist/core/override/provider-override-builder.js +0 -94
  46. package/dist/core/override/provider-override-builder.js.map +0 -1
  47. package/dist/core/test.d.ts +0 -48
  48. package/dist/core/test.d.ts.map +0 -1
  49. package/dist/core/test.js +0 -53
  50. package/dist/core/test.js.map +0 -1
  51. package/dist/core/testing-module-builder.d.ts +0 -98
  52. package/dist/core/testing-module-builder.d.ts.map +0 -1
  53. package/dist/core/testing-module-builder.js +0 -154
  54. package/dist/core/testing-module-builder.js.map +0 -1
  55. package/dist/core/testing-module.d.ts +0 -77
  56. package/dist/core/testing-module.d.ts.map +0 -1
  57. package/dist/core/testing-module.js +0 -99
  58. package/dist/core/testing-module.js.map +0 -1
  59. package/dist/errors/index.d.ts +0 -3
  60. package/dist/errors/index.d.ts.map +0 -1
  61. package/dist/errors/index.js +0 -3
  62. package/dist/errors/index.js.map +0 -1
  63. package/dist/errors/setup-error.d.ts +0 -9
  64. package/dist/errors/setup-error.d.ts.map +0 -1
  65. package/dist/errors/setup-error.js +0 -11
  66. package/dist/errors/setup-error.js.map +0 -1
  67. package/dist/errors/test-error.d.ts +0 -9
  68. package/dist/errors/test-error.d.ts.map +0 -1
  69. package/dist/errors/test-error.js +0 -15
  70. package/dist/errors/test-error.js.map +0 -1
  71. package/dist/index.d.ts +0 -14
  72. package/dist/mocks/index.d.ts +0 -4
  73. package/dist/mocks/index.d.ts.map +0 -1
  74. package/dist/mocks/index.js +0 -4
  75. package/dist/mocks/index.js.map +0 -1
  76. package/dist/mocks/nodemailer.d.ts +0 -10
  77. package/dist/mocks/nodemailer.d.ts.map +0 -1
  78. package/dist/mocks/nodemailer.js +0 -9
  79. package/dist/mocks/nodemailer.js.map +0 -1
  80. package/dist/storage/fake-storage.service.d.ts +0 -114
  81. package/dist/storage/fake-storage.service.d.ts.map +0 -1
  82. package/dist/storage/fake-storage.service.js +0 -233
  83. package/dist/storage/fake-storage.service.js.map +0 -1
  84. package/dist/storage/index.d.ts +0 -2
  85. package/dist/storage/index.d.ts.map +0 -1
  86. package/dist/storage/index.js +0 -2
  87. package/dist/storage/index.js.map +0 -1
@@ -1,290 +0,0 @@
1
- import { fetchMock } from 'cloudflare:test';
2
- /**
3
- * Wrapper around Cloudflare's fetchMock for declarative fetch mocking in tests
4
- *
5
- * Based on undici's MockAgent, fetchMock.get(origin) returns a MockPool for that origin.
6
- * The MockPool's intercept() method is used to define which requests to mock.
7
- *
8
- * @example
9
- * ```typescript
10
- * import { createFetchMock } from '@stratal/testing'
11
- *
12
- * const mock = createFetchMock()
13
- *
14
- * beforeEach(() => {
15
- * mock.activate()
16
- * mock.disableNetConnect()
17
- * })
18
- *
19
- * afterEach(() => {
20
- * mock.reset()
21
- * })
22
- *
23
- * it('should mock external API', async () => {
24
- * // Using helper method
25
- * mock.mockJsonResponse('https://api.example.com/data', { success: true })
26
- *
27
- * // Or using direct API
28
- * mock.get('https://api.example.com')
29
- * .intercept({ path: '/users', method: 'POST' })
30
- * .reply(201, JSON.stringify({ created: true }))
31
- *
32
- * const response = await fetch('https://api.example.com/data')
33
- * const json = await response.json()
34
- *
35
- * expect(json.success).toBe(true)
36
- * mock.assertNoPendingInterceptors()
37
- * })
38
- * ```
39
- */
40
- export class FetchMock {
41
- /**
42
- * Get a MockPool for the specified origin
43
- *
44
- * This is the underlying fetchMock.get() method that returns a MockPool
45
- * for mocking requests to the specified origin.
46
- *
47
- * @param origin - The origin URL (e.g., 'https://api.example.com')
48
- * @returns MockPool for chaining .intercept() and .reply()
49
- *
50
- * @example
51
- * ```typescript
52
- * // Mock a GET request
53
- * mock.get('https://api.example.com')
54
- * .intercept({ path: '/users', method: 'GET' })
55
- * .reply(200, JSON.stringify({ users: [] }))
56
- *
57
- * // Mock a POST request with body matching
58
- * mock.get('https://api.example.com')
59
- * .intercept({
60
- * path: '/users',
61
- * method: 'POST',
62
- * body: (body) => body.includes('test')
63
- * })
64
- * .reply(201, JSON.stringify({ created: true }))
65
- * ```
66
- */
67
- get(origin) {
68
- return fetchMock.get(origin);
69
- }
70
- /**
71
- * Activate fetch mocking for the current test
72
- *
73
- * @example
74
- * ```typescript
75
- * beforeEach(() => {
76
- * mock.activate()
77
- * })
78
- * ```
79
- */
80
- activate() {
81
- fetchMock.activate();
82
- }
83
- /**
84
- * Deactivate fetch mocking
85
- */
86
- deactivate() {
87
- fetchMock.deactivate();
88
- }
89
- /**
90
- * Disable all network connections, forcing all requests to use mocks
91
- *
92
- * @example
93
- * ```typescript
94
- * beforeEach(() => {
95
- * mock.activate()
96
- * mock.disableNetConnect() // Ensure all requests are mocked
97
- * })
98
- * ```
99
- */
100
- disableNetConnect() {
101
- fetchMock.disableNetConnect();
102
- }
103
- /**
104
- * Enable network connections for specific hosts
105
- *
106
- * @example
107
- * ```typescript
108
- * mock.enableNetConnect('localhost')
109
- * mock.enableNetConnect(/^https:\/\/trusted\.com/)
110
- * ```
111
- */
112
- enableNetConnect(host) {
113
- if (host) {
114
- fetchMock.enableNetConnect(host);
115
- return;
116
- }
117
- fetchMock.enableNetConnect();
118
- }
119
- /**
120
- * Assert that all defined interceptors were called
121
- *
122
- * @throws {Error} If there are pending interceptors that weren't matched
123
- *
124
- * @example
125
- * ```typescript
126
- * it('should call all mocked endpoints', async () => {
127
- * mock.mockJsonResponse('https://api.example.com/data', { data: [] })
128
- *
129
- * await fetch('https://api.example.com/data')
130
- *
131
- * mock.assertNoPendingInterceptors() // Pass
132
- * })
133
- * ```
134
- */
135
- assertNoPendingInterceptors() {
136
- fetchMock.assertNoPendingInterceptors();
137
- }
138
- /**
139
- * Reset all mocks and interceptors
140
- *
141
- * @example
142
- * ```typescript
143
- * afterEach(() => {
144
- * mock.reset()
145
- * })
146
- * ```
147
- */
148
- reset() {
149
- // Reset by deactivating
150
- fetchMock.deactivate();
151
- }
152
- /**
153
- * Helper method to mock JSON responses
154
- *
155
- * Automatically parses the URL into origin and path, and sets up the mock.
156
- *
157
- * @param url - Full URL to mock (e.g., 'https://api.example.com/users')
158
- * @param data - JSON data to return
159
- * @param options - Additional options for the mock
160
- *
161
- * @example
162
- * ```typescript
163
- * // Mock a GET request
164
- * mock.mockJsonResponse('https://api.example.com/users', { users: [] })
165
- *
166
- * // Mock a POST request
167
- * mock.mockJsonResponse(
168
- * 'https://api.example.com/users',
169
- * { created: true },
170
- * { method: 'POST', status: 201 }
171
- * )
172
- *
173
- * // With custom headers and delay
174
- * mock.mockJsonResponse(
175
- * 'https://api.example.com/users',
176
- * { users: [] },
177
- * {
178
- * status: 200,
179
- * method: 'GET',
180
- * headers: { 'X-Custom': 'value' },
181
- * delay: 100
182
- * }
183
- * )
184
- * ```
185
- */
186
- mockJsonResponse(url, data, options = {}) {
187
- const parsedUrl = new URL(url);
188
- const origin = `${parsedUrl.protocol}//${parsedUrl.host}`;
189
- const path = options.path ?? parsedUrl.pathname;
190
- const method = options.method ?? 'GET';
191
- const { status = 200, headers = {}, delay } = options;
192
- const defaultHeaders = {
193
- 'Content-Type': 'application/json',
194
- ...headers,
195
- };
196
- const mock = fetchMock
197
- .get(origin)
198
- .intercept({ path, method })
199
- .reply(status, JSON.stringify(data), { headers: defaultHeaders });
200
- if (delay) {
201
- return mock.delay(delay);
202
- }
203
- return mock;
204
- }
205
- /**
206
- * Helper method to mock error responses
207
- *
208
- * @param url - Full URL to mock
209
- * @param status - HTTP error status code
210
- * @param message - Optional error message
211
- * @param options - Additional options for the error mock
212
- *
213
- * @example
214
- * ```typescript
215
- * // Mock a 401 error
216
- * mock.mockError('https://api.example.com/fail', 401, 'Unauthorized')
217
- *
218
- * // Mock a 500 error with custom method
219
- * mock.mockError(
220
- * 'https://api.example.com/fail',
221
- * 500,
222
- * 'Server Error',
223
- * { method: 'POST' }
224
- * )
225
- * ```
226
- */
227
- mockError(url, status, message, options = {}) {
228
- const parsedUrl = new URL(url);
229
- const origin = `${parsedUrl.protocol}//${parsedUrl.host}`;
230
- const path = options.path ?? parsedUrl.pathname;
231
- const method = options.method ?? 'GET';
232
- const { headers = {} } = options;
233
- const body = message ? JSON.stringify({ error: message }) : '';
234
- const responseHeaders = message
235
- ? { 'Content-Type': 'application/json', ...headers }
236
- : headers;
237
- return fetchMock
238
- .get(origin)
239
- .intercept({ path, method })
240
- .reply(status, body, { headers: responseHeaders });
241
- }
242
- /**
243
- * Generic helper to mock any HTTP request
244
- *
245
- * @param origin - The origin URL (e.g., 'https://api.example.com')
246
- * @param options - Request matching and response options
247
- *
248
- * @example
249
- * ```typescript
250
- * mock.mockRequest('https://api.example.com', {
251
- * path: '/users',
252
- * method: 'PUT',
253
- * status: 200,
254
- * body: { updated: true }
255
- * })
256
- * ```
257
- */
258
- mockRequest(origin, options) {
259
- const { path, method = 'GET', status = 200, body } = options;
260
- return fetchMock
261
- .get(origin)
262
- .intercept({ path, method })
263
- .reply(status, body ? JSON.stringify(body) : '');
264
- }
265
- }
266
- /**
267
- * Factory function to create a new FetchMock instance
268
- *
269
- * @returns A new FetchMock instance
270
- *
271
- * @example
272
- * ```typescript
273
- * import { createFetchMock } from '@stratal/testing'
274
- *
275
- * const mock = createFetchMock()
276
- *
277
- * beforeEach(() => {
278
- * mock.activate()
279
- * mock.disableNetConnect()
280
- * })
281
- *
282
- * afterEach(() => {
283
- * mock.reset()
284
- * })
285
- * ```
286
- */
287
- export function createFetchMock() {
288
- return new FetchMock();
289
- }
290
- //# sourceMappingURL=fetch-mock.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch-mock.js","sourceRoot":"","sources":["../../../src/core/http/fetch-mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,MAAM,CAAC;aACX,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;aAC3B,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAA;IACpD,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CACV,MAAc,EACd,OAA2E;QAE3E,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;QAE5D,OAAO,SAAS;aACd,GAAG,CAAC,MAAM,CAAC;aACX,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;aAC3B,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;IAClD,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,eAAe;IAC9B,OAAO,IAAI,SAAS,EAAE,CAAA;AACvB,CAAC"}
@@ -1,48 +0,0 @@
1
- /**
2
- * Options for mocking JSON responses
3
- */
4
- export interface MockJsonOptions {
5
- /**
6
- * HTTP status code for the response
7
- * @default 200
8
- */
9
- status?: number;
10
- /**
11
- * Custom headers to include in the response
12
- */
13
- headers?: Record<string, string>;
14
- /**
15
- * Delay in milliseconds before responding
16
- */
17
- delay?: number;
18
- /**
19
- * HTTP method to match (GET, POST, PUT, PATCH, DELETE, etc.)
20
- * @default 'GET'
21
- */
22
- method?: string;
23
- /**
24
- * Specific path to override URL pathname
25
- * If not provided, the pathname from the URL will be used
26
- */
27
- path?: string;
28
- }
29
- /**
30
- * Options for mocking error responses
31
- */
32
- export interface MockErrorOptions {
33
- /**
34
- * Custom headers to include in the error response
35
- */
36
- headers?: Record<string, string>;
37
- /**
38
- * HTTP method to match (GET, POST, PUT, PATCH, DELETE, etc.)
39
- * @default 'GET'
40
- */
41
- method?: string;
42
- /**
43
- * Specific path to override URL pathname
44
- * If not provided, the pathname from the URL will be used
45
- */
46
- path?: string;
47
- }
48
- //# sourceMappingURL=fetch-mock.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch-mock.types.d.ts","sourceRoot":"","sources":["../../../src/core/http/fetch-mock.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEhC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEhC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACb"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=fetch-mock.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch-mock.types.js","sourceRoot":"","sources":["../../../src/core/http/fetch-mock.types.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- export { TestHttpClient } from './test-http-client';
2
- export { TestHttpRequest } from './test-http-request';
3
- export { TestResponse } from './test-response';
4
- export { FetchMock, createFetchMock } from './fetch-mock';
5
- export type { MockJsonOptions, MockErrorOptions } from './fetch-mock.types';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACzD,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA"}
@@ -1,5 +0,0 @@
1
- export { TestHttpClient } from './test-http-client';
2
- export { TestHttpRequest } from './test-http-request';
3
- export { TestResponse } from './test-response';
4
- export { FetchMock, createFetchMock } from './fetch-mock';
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
@@ -1,54 +0,0 @@
1
- import type { TestingModule } from '../testing-module';
2
- import { TestHttpRequest } from './test-http-request';
3
- /**
4
- * TestHttpClient
5
- *
6
- * Fluent HTTP client for making test requests.
7
- *
8
- * @example
9
- * ```typescript
10
- * const response = await module.http
11
- * .forHost('school.admsn.test')
12
- * .post('/api/v1/register')
13
- * .withBody({ schoolInfo: { name: 'Test' } })
14
- * .send()
15
- *
16
- * response.assertCreated()
17
- * ```
18
- */
19
- export declare class TestHttpClient {
20
- private readonly module;
21
- private defaultHeaders;
22
- private host;
23
- constructor(module: TestingModule);
24
- /**
25
- * Set the host for the request (used for tenant identification)
26
- */
27
- forHost(host: string): this;
28
- /**
29
- * Set default headers for all requests
30
- */
31
- withHeaders(headers: Record<string, string>): this;
32
- /**
33
- * Create a GET request
34
- */
35
- get(path: string): TestHttpRequest;
36
- /**
37
- * Create a POST request
38
- */
39
- post(path: string): TestHttpRequest;
40
- /**
41
- * Create a PUT request
42
- */
43
- put(path: string): TestHttpRequest;
44
- /**
45
- * Create a PATCH request
46
- */
47
- patch(path: string): TestHttpRequest;
48
- /**
49
- * Create a DELETE request
50
- */
51
- delete(path: string): TestHttpRequest;
52
- private createRequest;
53
- }
54
- //# sourceMappingURL=test-http-client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-http-client.d.ts","sourceRoot":"","sources":["../../../src/core/http/test-http-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,cAAc;IAIb,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,IAAI,CAAsB;gBAEL,MAAM,EAAE,aAAa;IAElD;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK3B;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAOlD;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAIlC;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAInC;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAIlC;;OAEG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAIpC;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAIrC,OAAO,CAAC,aAAa;CAGtB"}
@@ -1,75 +0,0 @@
1
- import { TestHttpRequest } from './test-http-request';
2
- /**
3
- * TestHttpClient
4
- *
5
- * Fluent HTTP client for making test requests.
6
- *
7
- * @example
8
- * ```typescript
9
- * const response = await module.http
10
- * .forHost('school.admsn.test')
11
- * .post('/api/v1/register')
12
- * .withBody({ schoolInfo: { name: 'Test' } })
13
- * .send()
14
- *
15
- * response.assertCreated()
16
- * ```
17
- */
18
- export class TestHttpClient {
19
- module;
20
- defaultHeaders = new Headers();
21
- host = null;
22
- constructor(module) {
23
- this.module = module;
24
- }
25
- /**
26
- * Set the host for the request (used for tenant identification)
27
- */
28
- forHost(host) {
29
- this.host = host;
30
- return this;
31
- }
32
- /**
33
- * Set default headers for all requests
34
- */
35
- withHeaders(headers) {
36
- for (const [key, value] of Object.entries(headers)) {
37
- this.defaultHeaders.set(key, value);
38
- }
39
- return this;
40
- }
41
- /**
42
- * Create a GET request
43
- */
44
- get(path) {
45
- return this.createRequest('GET', path);
46
- }
47
- /**
48
- * Create a POST request
49
- */
50
- post(path) {
51
- return this.createRequest('POST', path);
52
- }
53
- /**
54
- * Create a PUT request
55
- */
56
- put(path) {
57
- return this.createRequest('PUT', path);
58
- }
59
- /**
60
- * Create a PATCH request
61
- */
62
- patch(path) {
63
- return this.createRequest('PATCH', path);
64
- }
65
- /**
66
- * Create a DELETE request
67
- */
68
- delete(path) {
69
- return this.createRequest('DELETE', path);
70
- }
71
- createRequest(method, path) {
72
- return new TestHttpRequest(method, path, this.defaultHeaders, this.module, this.host);
73
- }
74
- }
75
- //# sourceMappingURL=test-http-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-http-client.js","sourceRoot":"","sources":["../../../src/core/http/test-http-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,cAAc;IAII;IAHrB,cAAc,GAAY,IAAI,OAAO,EAAE,CAAA;IACvC,IAAI,GAAkB,IAAI,CAAA;IAElC,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAI,CAAC;IAEvD;;OAEG;IACH,OAAO,CAAC,IAAY;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,OAA+B;QACzC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACrC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACxC,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,IAAY;QACf,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACzC,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACxC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAY;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAY;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IAC3C,CAAC;IAEO,aAAa,CAAC,MAAc,EAAE,IAAY;QAChD,OAAO,IAAI,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;IACvF,CAAC;CACF"}
@@ -1,44 +0,0 @@
1
- import type { TestingModule } from '../testing-module';
2
- import { TestResponse } from './test-response';
3
- /**
4
- * TestHttpRequest
5
- *
6
- * Request builder with fluent API for configuring test HTTP requests.
7
- *
8
- * @example
9
- * ```typescript
10
- * const response = await module.http
11
- * .post('/api/v1/register')
12
- * .withBody({ name: 'Test School' })
13
- * .withHeaders({ 'X-Custom': 'value' })
14
- * .send()
15
- * ```
16
- */
17
- export declare class TestHttpRequest {
18
- private readonly method;
19
- private readonly path;
20
- private readonly module;
21
- private readonly host;
22
- private body;
23
- private requestHeaders;
24
- constructor(method: string, path: string, headers: Headers, module: TestingModule, host?: string | null);
25
- /**
26
- * Set the request body
27
- */
28
- withBody(data: unknown): this;
29
- /**
30
- * Add headers to the request
31
- */
32
- withHeaders(headers: Record<string, string>): this;
33
- /**
34
- * Set Content-Type to application/json
35
- */
36
- asJson(): this;
37
- /**
38
- * Send the request and return response
39
- *
40
- * Calls module.fetch() - NOT SELF.fetch()
41
- */
42
- send(): Promise<TestResponse>;
43
- }
44
- //# sourceMappingURL=test-http-request.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-http-request.d.ts","sourceRoot":"","sources":["../../../src/core/http/test-http-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;;;;;;;;;;;;GAaG;AACH,qBAAa,eAAe;IAK1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAErB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI;IARtB,OAAO,CAAC,IAAI,CAAgB;IAC5B,OAAO,CAAC,cAAc,CAAS;gBAGb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAC7B,OAAO,EAAE,OAAO,EACC,MAAM,EAAE,aAAa,EACrB,IAAI,GAAE,MAAM,GAAG,IAAW;IAK5C;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAK7B;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAOlD;;OAEG;IACH,MAAM,IAAI,IAAI;IAKd;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC;CAkBnC"}
@@ -1,75 +0,0 @@
1
- import { TestResponse } from './test-response';
2
- /**
3
- * TestHttpRequest
4
- *
5
- * Request builder with fluent API for configuring test HTTP requests.
6
- *
7
- * @example
8
- * ```typescript
9
- * const response = await module.http
10
- * .post('/api/v1/register')
11
- * .withBody({ name: 'Test School' })
12
- * .withHeaders({ 'X-Custom': 'value' })
13
- * .send()
14
- * ```
15
- */
16
- export class TestHttpRequest {
17
- method;
18
- path;
19
- module;
20
- host;
21
- body = null;
22
- requestHeaders;
23
- constructor(method, path, headers, module, host = null) {
24
- this.method = method;
25
- this.path = path;
26
- this.module = module;
27
- this.host = host;
28
- this.requestHeaders = new Headers(headers);
29
- }
30
- /**
31
- * Set the request body
32
- */
33
- withBody(data) {
34
- this.body = data;
35
- return this;
36
- }
37
- /**
38
- * Add headers to the request
39
- */
40
- withHeaders(headers) {
41
- for (const [key, value] of Object.entries(headers)) {
42
- this.requestHeaders.set(key, value);
43
- }
44
- return this;
45
- }
46
- /**
47
- * Set Content-Type to application/json
48
- */
49
- asJson() {
50
- this.requestHeaders.set('Content-Type', 'application/json');
51
- return this;
52
- }
53
- /**
54
- * Send the request and return response
55
- *
56
- * Calls module.fetch() - NOT SELF.fetch()
57
- */
58
- async send() {
59
- // Auto-set Content-Type for body
60
- if (this.body && !this.requestHeaders.has('Content-Type')) {
61
- this.requestHeaders.set('Content-Type', 'application/json');
62
- }
63
- // Build request
64
- const url = new URL(this.path, `http://${this.host ?? 'localhost'}`);
65
- const request = new Request(url.toString(), {
66
- method: this.method,
67
- headers: this.requestHeaders,
68
- body: this.body ? JSON.stringify(this.body) : null,
69
- });
70
- // Call module.fetch() - NO SELF.fetch()
71
- const response = await this.module.fetch(request);
72
- return new TestResponse(response);
73
- }
74
- }
75
- //# sourceMappingURL=test-http-request.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-http-request.js","sourceRoot":"","sources":["../../../src/core/http/test-http-request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,eAAe;IAKT;IACA;IAEA;IACA;IARV,IAAI,GAAY,IAAI,CAAA;IACpB,cAAc,CAAS;IAE/B,YACkB,MAAc,EACd,IAAY,EAC7B,OAAgB,EACC,MAAqB,EACrB,OAAsB,IAAI;QAJ1B,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAEZ,WAAM,GAAN,MAAM,CAAe;QACrB,SAAI,GAAJ,IAAI,CAAsB;QAE3C,IAAI,CAAC,cAAc,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IAC3C,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,IAAa;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,OAAO,IAAI,CAAA;IACZ,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,OAA+B;QAC1C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACpD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACpC,CAAC;QACD,OAAO,IAAI,CAAA;IACZ,CAAC;IAED;;OAEG;IACH,MAAM;QACL,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAA;QAC3D,OAAO,IAAI,CAAA;IACZ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI;QACT,iCAAiC;QACjC,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,GAA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