mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-16 00:14:37 +00:00
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:
1 parent
5c83429a79
commit
2b91c40e37
3 files changed
+24
-16
No files matched your search
@@ -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" */
|
||||
|
||||
Reference in new issue
Block a user