* Convenience: create a two-phase mock (device/code → token polling). * The first matching request returns a device-code response; all subsequent * requests return token responses.
( deviceOverrides?: Record<string, unknown>, tokenOverrides?: Record<string, unknown>, )
| 77 | * requests return token responses. |
| 78 | */ |
| 79 | function mockDeviceCodeFlow( |
| 80 | deviceOverrides?: Record<string, unknown>, |
| 81 | tokenOverrides?: Record<string, unknown>, |
| 82 | ): FetchMock { |
| 83 | let first = true; |
| 84 | return (_url: string, opts?: RequestInit) => { |
| 85 | if (first) { |
| 86 | first = false; |
| 87 | const body = opts?.body instanceof URLSearchParams |
| 88 | ? opts.body |
| 89 | : new URLSearchParams(String(opts?.body ?? '')); |
| 90 | return Promise.resolve(deviceCodeResponse(body, deviceOverrides)); |
| 91 | } |
| 92 | return Promise.resolve(tokenResponse(tokenOverrides)); |
| 93 | }; |
| 94 | } |
| 95 | |
| 96 | const originalFetch = globalThis.fetch; |
| 97 |
nothing calls this directly
no test coverage detected