fix(tests): address edge cases in mock infrastructure

- Prevent spy leak on double mockFetch() call
- Differentiate body types (URLSearchParams, ArrayBuffer, Blob, ReadableStream)
- Fix route path parsing to preserve spaces
- Escape regex special chars before wildcard replacement
- Remove unused MockResponse.error and MockRoute interface
This commit is contained in:
kaitranntt committed 2026-01-23 23:41:49 -05:00
1 parent 5c83429a79
commit 2b91c40e37
3 files changed
+24 -16

No files matched your search

-12
View File
@@ -21,23 +21,11 @@ export interface MockResponse {
headers?: Record<string, string>;
/** Delay in ms before responding (for timeout testing) */
delay?: number;
/** Throw error instead of responding */
error?: Error;
}
/** Route key format: "METHOD /path" */
export type RouteKey = `${HttpMethod} ${string}`;
/** Mock route configuration */
export interface MockRoute {
/** HTTP method */
method: HttpMethod;
/** URL path pattern (string or regex) */
path: string | RegExp;
/** Response to return */
response: MockResponse;
}
/** Configuration for createMockHttpServer */
export interface MockHttpServerConfig {
/** Route definitions - key format: "METHOD /path" */