Skip to content

Commit

Permalink
fix(test): fetch api cache affected test
Browse files Browse the repository at this point in the history
  • Loading branch information
giannif committed Feb 17, 2021
1 parent 1740d15 commit db8cd9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/fetch-api/src/__tests__/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe('response parsing', () => {
test('error', async () => {
fetchMock.mockReject(new Error('some crazy error'))
try {
await gf.related('12345 dslfjdlskj')
await gf.related('some crazy error')
} catch (error) {
expect(error.message).toBe('some crazy error')
}
Expand All @@ -200,7 +200,7 @@ describe('response parsing', () => {
test('synthetic response', async () => {
fetchMock.mockResponseOnce(JSON.stringify(syntheticResponse))
try {
await gf.related('12345 dslfjdlskj')
await gf.related('synthic error')
} catch (error) {
expect(error.message).toBe('synthetic response')
}
Expand Down
4 changes: 3 additions & 1 deletion packages/fetch-api/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ function request(url: string, normalizer: (a: any) => any = identity, noCache: b
fetchError = new FetchError(unexpectedError.message)
// if the request fails with an unspecfied error,
// the user can request again after the error timeout
requestMap[url].isError = true
if (requestMap[url]) {
requestMap[url].isError = true
}
}
throw fetchError
}
Expand Down

0 comments on commit db8cd9b

Please sign in to comment.