(mock, run)
| 8 | const sdk = await importBundledModule(sdkPath); |
| 9 | |
| 10 | function withMockedFetch(mock, run) { |
| 11 | const hadFetch = Object.prototype.hasOwnProperty.call(globalThis, "fetch"); |
| 12 | const originalFetch = globalThis.fetch; |
| 13 | globalThis.fetch = mock; |
| 14 | return Promise.resolve() |
| 15 | .then(run) |
| 16 | .finally(() => { |
| 17 | if (hadFetch) { |
| 18 | globalThis.fetch = originalFetch; |
| 19 | } else { |
| 20 | delete globalThis.fetch; |
| 21 | } |
| 22 | }); |
| 23 | } |
| 24 | |
| 25 | test("fetchJSON returns parsed body on success", async () => { |
| 26 | const seen = []; |
no test coverage detected