(
responseData: unknown,
options: { ok?: boolean; status?: number; headers?: Record<string, string> } = {}
)
| 62 | * Wraps the @sim/testing createMockFetch with tool-specific additions. |
| 63 | */ |
| 64 | export function createToolMockFetch( |
| 65 | responseData: unknown, |
| 66 | options: { ok?: boolean; status?: number; headers?: Record<string, string> } = {} |
| 67 | ) { |
| 68 | const { ok = true, status = 200, headers = { 'Content-Type': 'application/json' } } = options |
| 69 | |
| 70 | const mockFetchConfig: MockFetchResponse = { |
| 71 | json: responseData, |
| 72 | status, |
| 73 | ok, |
| 74 | headers, |
| 75 | text: typeof responseData === 'string' ? responseData : JSON.stringify(responseData), |
| 76 | } |
| 77 | |
| 78 | const baseMockFetch = createBaseMockFetch(mockFetchConfig) |
| 79 | ;(baseMockFetch as MockFetch).preconnect = vi.fn() |
| 80 | |
| 81 | return baseMockFetch as MockFetch |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Creates a mock error fetch function. |
no outgoing calls
no test coverage detected