| 55 | }; |
| 56 | |
| 57 | export interface MockHttpBridge { |
| 58 | // Route registration (return `this` for chaining) |
| 59 | onGet<TData = unknown>(pathPattern: string, handler: MockHttpHandler<undefined, TData>): this; |
| 60 | onPost<TBody = unknown, TData = unknown>(pathPattern: string, handler: MockHttpHandler<TBody, TData>): this; |
| 61 | onPut<TBody = unknown, TData = unknown>(pathPattern: string, handler: MockHttpHandler<TBody, TData>): this; |
| 62 | onPatch<TBody = unknown, TData = unknown>(pathPattern: string, handler: MockHttpHandler<TBody, TData>): this; |
| 63 | onDelete<TData = unknown>(pathPattern: string, handler: MockHttpHandler<undefined, TData>): this; |
| 64 | |
| 65 | // WS event emission |
| 66 | /** |
| 67 | * Dispatch payload to all listeners subscribed via wsEmitter(eventName).on(cb). |
| 68 | * Synchronous dispatch: all listeners receive event before call stack unwinds. |
| 69 | */ |
| 70 | emit(eventName: string, payload: unknown): void; |
| 71 | |
| 72 | // Inspection helpers |
| 73 | /** Recorded call log, chronological (excludes pre-reset history). */ |
| 74 | calls: ReadonlyArray<{ |
| 75 | method: HttpMethod; |
| 76 | path: string; |
| 77 | pathPattern: string; |
| 78 | params: Record<string, string>; |
| 79 | query: Record<string, string>; |
| 80 | body: unknown; |
| 81 | }>; |
| 82 | /** Registered (method, pathPattern) pair count. */ |
| 83 | readonly routeCount: number; |
| 84 | /** Total WS listener count (across all events). */ |
| 85 | readonly wsListenerCount: number; |
| 86 | |
| 87 | // Lifecycle |
| 88 | /** |
| 89 | * Clear routes, WS listeners, and calls history. |
| 90 | * Recommended in beforeEach; only affects this instance. |
| 91 | */ |
| 92 | reset(): void; |
| 93 | |
| 94 | /** |
| 95 | * Return an object suitable for vi.mock('@/common/adapter/httpBridge', () => ...). |
| 96 | * Keys match all named exports from httpBridge.ts to avoid TS missing-export errors. |
| 97 | */ |
| 98 | asModule(): { |
| 99 | httpGet: typeof import('@/common/adapter/httpBridge').httpGet; |
| 100 | httpPost: typeof import('@/common/adapter/httpBridge').httpPost; |
| 101 | httpPut: typeof import('@/common/adapter/httpBridge').httpPut; |
| 102 | httpPatch: typeof import('@/common/adapter/httpBridge').httpPatch; |
| 103 | httpDelete: typeof import('@/common/adapter/httpBridge').httpDelete; |
| 104 | stubProvider: typeof import('@/common/adapter/httpBridge').stubProvider; |
| 105 | withResponseMap: typeof import('@/common/adapter/httpBridge').withResponseMap; |
| 106 | wsEmitter: typeof import('@/common/adapter/httpBridge').wsEmitter; |
| 107 | wsMappedEmitter: typeof import('@/common/adapter/httpBridge').wsMappedEmitter; |
| 108 | stubEmitter: typeof import('@/common/adapter/httpBridge').stubEmitter; |
| 109 | httpRequest: typeof import('@/common/adapter/httpBridge').httpRequest; |
| 110 | getBaseUrl: typeof import('@/common/adapter/httpBridge').getBaseUrl; |
| 111 | BackendHttpError: typeof import('@/common/adapter/httpBridge').BackendHttpError; |
| 112 | isBackendHttpError: typeof import('@/common/adapter/httpBridge').isBackendHttpError; |
| 113 | }; |
| 114 | } |
no outgoing calls
no test coverage detected