(responseBodies: unknown[], calls: FetchCall[])
| 577 | } |
| 578 | |
| 579 | function recordingFetchSequence(responseBodies: unknown[], calls: FetchCall[]): typeof fetch { |
| 580 | let index = 0; |
| 581 | return (async (input: Parameters<typeof fetch>[0], init?: Parameters<typeof fetch>[1]) => { |
| 582 | calls.push({ url: fetchInputUrl(input), init: init ?? {} }); |
| 583 | const responseBody = responseBodies[Math.min(index, responseBodies.length - 1)]; |
| 584 | index++; |
| 585 | return new Response(JSON.stringify(responseBody), { |
| 586 | status: 200, |
| 587 | headers: { 'content-type': 'application/json' }, |
| 588 | }); |
| 589 | }) as typeof fetch; |
| 590 | } |
| 591 | |
| 592 | function fetchInputUrl(input: Parameters<typeof fetch>[0]): string { |
| 593 | if (typeof input === 'string') return input; |
no test coverage detected