Skip to content

Commit

Permalink
re-write new custom context tests to be the same as other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TkDodo committed Mar 25, 2022
1 parent 2dfc993 commit 9d702a3
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/reactjs/tests/useIsFetching.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe('useIsFetching', () => {
useQuery(
key,
async () => {
await sleep(1000)
await sleep(50)
return 'test'
},
{
Expand All @@ -189,14 +189,18 @@ describe('useIsFetching', () => {
)
}

const rendered = renderWithClient(queryClient, <Page />, {
context,
})
const { findByText, getByRole } = renderWithClient(
queryClient,
<Page />,
{
context,
}
)

await waitFor(() => rendered.getByText('isFetching: 0'))
fireEvent.click(rendered.getByText('setReady'))
await waitFor(() => rendered.getByText('isFetching: 1'))
await waitFor(() => rendered.getByText('isFetching: 0'))
await findByText('isFetching: 0')
fireEvent.click(getByRole('button', { name: /setReady/i }))
await findByText('isFetching: 1')
await findByText('isFetching: 0')
})

it('should throw if the context is not passed to useIsFetching', async () => {
Expand Down

0 comments on commit 9d702a3

Please sign in to comment.