mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
12 lines
410 B
TypeScript
12 lines
410 B
TypeScript
import { vi, type Mock } from 'vitest'
|
|
|
|
export interface FetchStubHandler {
|
|
(input: Parameters<typeof fetch>[0], init?: Parameters<typeof fetch>[1]): Promise<Response>
|
|
}
|
|
|
|
export type FetchStub = Mock<FetchStubHandler> & { preconnect: typeof fetch.preconnect }
|
|
|
|
export function createFetchStub(handler: FetchStubHandler): FetchStub {
|
|
return Object.assign(vi.fn(handler), { preconnect: fetch.preconnect })
|
|
}
|