Skip to content

Commit

Permalink
Update hooks.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
koji committed Mar 5, 2024
1 parent aebac48 commit 26a0198
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/src/resources/health/__tests__/hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@ vi.mock('@opentrons/react-api-client')

describe('useRobotInitializationStatus', () => {
it('should return "INITIALIZING" when response status code is 503', () => {
vi.mocked(useHealthQuery).mockImplementation(({ onSuccess }) => {
vi.mocked(useHealthQuery).mockImplementation(({ onSuccess }: any) =>
onSuccess({ status: 503 })
})
)
const { result } = renderHook(() => useRobotInitializationStatus())
expect(result.current).toBe(INIT_STATUS.INITIALIZING)
})

it('should return "SUCCEEDED" when response status code is 200', () => {
vi.mocked(useHealthQuery).mockImplementation(({ onSuccess }) => {
vi.mocked(useHealthQuery).mockImplementation(({ onSuccess }: any) =>
onSuccess({ status: 200 })
})
)
const { result } = renderHook(() => useRobotInitializationStatus())
expect(result.current).toBe(INIT_STATUS.SUCCEEDED)
})

it('should return "FAILED" when response status code is 500', () => {
vi.mocked(useHealthQuery).mockImplementation(({ onSuccess }) => {
vi.mocked(useHealthQuery).mockImplementation(({ onSuccess }: any) =>
onSuccess({ status: 500 })
})
)
const { result } = renderHook(() => useRobotInitializationStatus())
expect(result.current).toBe(INIT_STATUS.FAILED)
})

it('should return null when response status code is not 200, 500, or 503.', () => {
vi.mocked(useHealthQuery).mockImplementation(({ onSuccess }) => {
vi.mocked(useHealthQuery).mockImplementation(({ onSuccess }: any) =>
onSuccess({ status: 404 })
})
)
const { result } = renderHook(() => useRobotInitializationStatus())
expect(result.current).toBeNull()
})
Expand Down

0 comments on commit 26a0198

Please sign in to comment.