Skip to content

Commit

Permalink
add error case
Browse files Browse the repository at this point in the history
  • Loading branch information
ajay-sentry committed Apr 25, 2024
1 parent 288b6f3 commit 91f626f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/services/user/useInternalUser.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ afterAll(() => {
})

describe('useInternalUser', () => {
function setup() {
function setup(hasError = false) {
server.use(
rest.get('/internal/user', (req, res, ctx) => {
if (hasError) {
return res(ctx.status(400), ctx.json({}))
}
return res(
ctx.status(200),
ctx.json({
Expand Down Expand Up @@ -60,4 +63,14 @@ describe('useInternalUser', () => {
)
})
})

describe('when hook call errors', () => {
it('returns empty object', async () => {
setup(true)

const { result } = renderHook(() => useInternalUser({}), { wrapper })

await waitFor(() => expect(result.current.data).toStrictEqual({}))
})
})
})

0 comments on commit 91f626f

Please sign in to comment.