| 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); |