Builds a minimal SecureFetchResponse-shaped object for tests.
(
status: number,
options: { headers?: Record<string, string>; body?: string } = {}
)
| 16 | |
| 17 | /** Builds a minimal SecureFetchResponse-shaped object for tests. */ |
| 18 | function fakeResponse( |
| 19 | status: number, |
| 20 | options: { headers?: Record<string, string>; body?: string } = {} |
| 21 | ) { |
| 22 | const headers = options.headers ?? {} |
| 23 | return { |
| 24 | ok: status >= 200 && status < 300, |
| 25 | status, |
| 26 | statusText: `status-${status}`, |
| 27 | headers: { get: (name: string) => headers[name.toLowerCase()] ?? null }, |
| 28 | body: null, |
| 29 | text: async () => options.body ?? '', |
| 30 | json: async () => JSON.parse(options.body ?? '{}'), |
| 31 | arrayBuffer: async () => new ArrayBuffer(0), |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | const FAST_RETRY = { initialDelayMs: 1, maxDelayMs: 2, maxRetries: 3 } |
| 36 |