( response: Response, fn: () => Promise<T> )
| 155 | }); |
| 156 | |
| 157 | function withMockedFetch<T>( |
| 158 | response: Response, |
| 159 | fn: () => Promise<T> |
| 160 | ): Promise<T> { |
| 161 | const original = globalThis.fetch; |
| 162 | const stub = (): Promise<Response> => Promise.resolve(response); |
| 163 | |
| 164 | Object.assign(globalThis, { fetch: stub }); |
| 165 | |
| 166 | return fn().finally(() => { |
| 167 | Object.assign(globalThis, { fetch: original }); |
| 168 | }); |
| 169 | } |
| 170 | |
| 171 | describe("canDisconnect", () => { |
| 172 | test("rejects when the target provider isn't linked to the user", () => { |