Skip to content

Commit 449b6a2

Browse files
committed
Add delays to remove React 17 conditional
1 parent e5033b5 commit 449b6a2

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

src/react/hooks/__tests__/useQuery.test.tsx

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4079,12 +4079,14 @@ describe("useQuery Hook", () => {
40794079
errors: [new GraphQLError("Intentional error")],
40804080
},
40814081
maxUsageCount: Number.POSITIVE_INFINITY,
4082+
delay: 20,
40824083
},
40834084
{
40844085
request: { query: query2, variables: { id: 1 } },
40854086
result: {
40864087
data: { person: { __typename: "Person", id: 1, lastName: "Doe" } },
40874088
},
4089+
delay: 20,
40884090
},
40894091
]),
40904092
cache: new InMemoryCache(),
@@ -4167,28 +4169,24 @@ describe("useQuery Hook", () => {
41674169

41684170
await act(() => user.click(screen.getByText("Run 2nd query")));
41694171

4170-
if (React.version.startsWith("17")) {
4171-
{
4172-
const { snapshot } = await Profiler.takeRender();
4172+
{
4173+
const { snapshot } = await Profiler.takeRender();
41734174

4174-
expect(snapshot.useQueryResult).toMatchObject({
4175-
data: undefined,
4176-
error: new ApolloError({
4177-
graphQLErrors: [new GraphQLError("Intentional error")],
4178-
}),
4179-
loading: false,
4180-
networkStatus: NetworkStatus.error,
4181-
});
4175+
expect(snapshot.useQueryResult).toMatchObject({
4176+
data: undefined,
4177+
error: new ApolloError({
4178+
graphQLErrors: [new GraphQLError("Intentional error")],
4179+
}),
4180+
loading: false,
4181+
networkStatus: NetworkStatus.error,
4182+
});
41824183

4183-
// React 17 contains this additional render that we do not see on React
4184-
// 18
4185-
expect(snapshot.useLazyQueryResult).toMatchObject({
4186-
called: true,
4187-
data: undefined,
4188-
loading: true,
4189-
networkStatus: NetworkStatus.loading,
4190-
});
4191-
}
4184+
expect(snapshot.useLazyQueryResult).toMatchObject({
4185+
called: true,
4186+
data: undefined,
4187+
loading: true,
4188+
networkStatus: NetworkStatus.loading,
4189+
});
41924190
}
41934191

41944192
{
@@ -4228,7 +4226,7 @@ describe("useQuery Hook", () => {
42284226

42294227
await act(() => user.click(screen.getByText("Reload 1st query")));
42304228

4231-
if (React.version.startsWith("17")) {
4229+
{
42324230
const { snapshot } = await Profiler.takeRender();
42334231

42344232
expect(snapshot.useQueryResult).toMatchObject({

0 commit comments

Comments
 (0)