MCPcopy Index your code
hub / github.com/simstudioai/sim / fakeResponse

Function fakeResponse

apps/sim/lib/knowledge/documents/utils.test.ts:18–33  ·  view source on GitHub ↗

Builds a minimal SecureFetchResponse-shaped object for tests.

(
  status: number,
  options: { headers?: Record<string, string>; body?: string } = {}
)

Source from the content-addressed store, hash-verified

16
17/** Builds a minimal SecureFetchResponse-shaped object for tests. */
18function fakeResponse(
19 status: number,
20 options: { headers?: Record<string, string>; body?: string } = {}
21) {
22 const headers = options.headers ?? {}
23 return {
24 ok: status >= 200 && status < 300,
25 status,
26 statusText: `status-${status}`,
27 headers: { get: (name: string) => headers[name.toLowerCase()] ?? null },
28 body: null,
29 text: async () => options.body ?? '',
30 json: async () => JSON.parse(options.body ?? '{}'),
31 arrayBuffer: async () => new ArrayBuffer(0),
32 }
33}
34
35const FAST_RETRY = { initialDelayMs: 1, maxDelayMs: 2, maxRetries: 3 }
36

Callers 1

utils.test.tsFile · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected