MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / createMockResponse

Function createMockResponse

apps/web/src/lib/utils.test.ts:46–67  ·  view source on GitHub ↗
(
    status: number,
    statusText: string,
    jsonData: unknown,
    shouldJsonFail = false
  )

Source from the content-addressed store, hash-verified

44
45 const response = {
46 ok: status >= 200 && status < 300,
47 status,
48 statusText,
49 json: jsonMock,
50 } as unknown as Response;
51
52 return { response, jsonMock };
53 };
54
55 const testSchema = z.object({
56 id: z.number(),
57 name: z.string(),
58 email: z.email(),
59 });
60
61 const validData = {
62 id: 1,
63 name: 'John Doe',
64 email: 'john@example.com',
65 };
66
67 it('should successfully parse valid response data', async () => {
68 const { response, jsonMock } = createMockResponse(200, 'OK', validData);
69
70 const result = await parseResultJsonWithZodSchema(response, testSchema);

Callers 1

utils.test.tsFile · 0.70

Calls 1

rejectMethod · 0.80

Tested by

no test coverage detected