MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / withMockedFetch

Function withMockedFetch

apps/api/tests/lib/oauth/oauth.utils.test.ts:157–169  ·  view source on GitHub ↗
(
  response: Response,
  fn: () => Promise<T>
)

Source from the content-addressed store, hash-verified

155});
156
157function 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
171describe("canDisconnect", () => {
172 test("rejects when the target provider isn't linked to the user", () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected