Skip to content

Commit

Permalink
Use snapshot directly to call fetchMore
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Nov 4, 2024
1 parent f0747e7 commit cc454a8
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/react/hooks/__tests__/useSuspenseQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10596,7 +10596,6 @@ describe("useSuspenseQuery", () => {
});
});

const user = userEvent.setup();
const client = new ApolloClient({
cache: new InMemoryCache(),
link,
Expand Down Expand Up @@ -10630,24 +10629,10 @@ describe("useSuspenseQuery", () => {
const result = useSuspenseQuery(query, {
variables: { offset: 0, limit: 2 },
});
const { data, fetchMore } = result;

renderStream.mergeSnapshot({ result });

return (
<button
onClick={() =>
fetchMore({
variables: {
offset: data.letters.length,
limit: data.letters.length + 1,
},
})
}
>
Fetch next
</button>
);
return null;
}

renderStream.render(
Expand Down Expand Up @@ -10681,7 +10666,10 @@ describe("useSuspenseQuery", () => {
});
}

await act(() => user.click(screen.getByText("Fetch next")));
const { snapshot } = renderStream.getCurrentRender();
await act(() =>
snapshot.result!.fetchMore({ variables: { offset: 2 } }).catch(() => {})
);

{
const { renderedComponents } = await renderStream.takeRender();
Expand Down

0 comments on commit cc454a8

Please sign in to comment.