Claude commited on
Commit
0787843
·
unverified ·
1 Parent(s): 9097545

fix: add json() mock to get() error test

Browse files

The get() helper now parses error response bodies (like post/put/del).
The test mock needs to provide a json() method on error responses.

https://claude.ai/code/session_01NuG9pRMcEHDi4SsKtEHoCj

frontend/src/lib/__tests__/api.test.ts CHANGED
@@ -35,12 +35,14 @@ describe('fetchCorpora', () => {
35
  mockFetch.mockResolvedValueOnce({
36
  ok: false,
37
  status: 404,
 
38
  })
39
 
40
  await expect(api.fetchCorpora()).rejects.toThrow(api.ApiError)
41
  await mockFetch.mockResolvedValueOnce({
42
  ok: false,
43
  status: 500,
 
44
  })
45
  await expect(api.fetchCorpora()).rejects.toThrow('HTTP 500')
46
  })
 
35
  mockFetch.mockResolvedValueOnce({
36
  ok: false,
37
  status: 404,
38
+ json: () => Promise.resolve(null),
39
  })
40
 
41
  await expect(api.fetchCorpora()).rejects.toThrow(api.ApiError)
42
  await mockFetch.mockResolvedValueOnce({
43
  ok: false,
44
  status: 500,
45
+ json: () => Promise.resolve(null),
46
  })
47
  await expect(api.fetchCorpora()).rejects.toThrow('HTTP 500')
48
  })