Skip to content

Commit

Permalink
Update test that checks changes to context between renders
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Oct 17, 2023
1 parent 99dcb87 commit 5e7a5d2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/react/hooks/__tests__/useInteractiveQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,7 @@ it("applies `context` on next fetch when it changes between renders", async () =

const user = userEvent.setup();

const query: TypedDocumentNode<Data> = gql`
const query: TypedDocumentNode<Data, never> = gql`
query {
context
}
Expand All @@ -2050,16 +2050,17 @@ it("applies `context` on next fetch when it changes between renders", async () =

function Parent() {
const [phase, setPhase] = React.useState("initial");
const [queryRef, { refetch }] = useInteractiveQuery(query, {
const [queryRef, loadQuery, { refetch }] = useInteractiveQuery(query, {
context: { phase },
});

return (
<>
<button onClick={() => setPhase("rerender")}>Update context</button>
<button onClick={() => refetch()}>Refetch</button>
<button onClick={() => loadQuery()}>Load query</button>
<Suspense fallback={<SuspenseFallback />}>
<Context queryRef={queryRef} />
{queryRef && <Context queryRef={queryRef} />}
</Suspense>
</>
);
Expand All @@ -2081,6 +2082,8 @@ it("applies `context` on next fetch when it changes between renders", async () =

render(<App />);

await act(() => user.click(screen.getByText("Load query")));

expect(await screen.findByTestId("context")).toHaveTextContent("initial");

await act(() => user.click(screen.getByText("Update context")));
Expand Down

0 comments on commit 5e7a5d2

Please sign in to comment.