public commit

This commit is contained in:
dswbx
2024-11-16 12:01:47 +01:00
commit 90f80c4280
582 changed files with 49291 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import { jest } from "bun:test";
let _oldFetch: typeof fetch;
export function mockFetch(responseMethods: Partial<Response>) {
_oldFetch = global.fetch;
// @ts-ignore
global.fetch = jest.fn(() => Promise.resolve(responseMethods));
}
export function mockFetch2(newFetch: (input: RequestInfo, init: RequestInit) => Promise<Response>) {
_oldFetch = global.fetch;
// @ts-ignore
global.fetch = jest.fn(newFetch);
}
export function unmockFetch() {
global.fetch = _oldFetch;
}