Skip to content

Commit

Permalink
Add variant of the useRefresh() test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jg210 committed Mar 9, 2024
1 parent 6416407 commit 476fc98
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/__tests__/useRefresh.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,17 @@ describe("useRefresh", () => {
});
waitFor(() => expect(result.current.refreshing).toEqual(false));
});

it("refetch resolves after 100ms", async () => {
const refetch = () => {
return new Promise<void>((resolve) => setTimeout(() => resolve(), 100));
};
const { result } = renderHook(() => useRefresh(refetch));
expect(result.current.refreshing).toEqual(false);
await act(async () => {
await result.current.onRefresh();
expect(result.current.refreshing).toEqual(true);
});
waitFor(() => expect(result.current.refreshing).toEqual(false));
});
});

0 comments on commit 476fc98

Please sign in to comment.