Skip to content

Commit cccf4e8

Browse files
committed
Update useSuspenseQuery tests to be more friendly between react versions
1 parent 9ceec34 commit cccf4e8

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/react/hooks/__tests__/useSuspenseQuery/streamDefer20220824.test.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,21 @@ test("adds partial data and does not throw errors returned in incremental chunks
13401340
}
13411341

13421342
subject.next(friends[0]);
1343+
1344+
{
1345+
const { snapshot, renderedComponents } = await takeRender();
1346+
1347+
expect(renderedComponents).toStrictEqual(["useSuspenseQuery"]);
1348+
expect(snapshot).toStrictEqualTyped({
1349+
data: markAsStreaming({
1350+
friendList: [{ __typename: "Friend", id: "1", name: "Luke" }],
1351+
}),
1352+
dataState: "streaming",
1353+
networkStatus: NetworkStatus.streaming,
1354+
error: undefined,
1355+
});
1356+
}
1357+
13431358
subject.next(new Error("Could not get friend"));
13441359

13451360
{
@@ -1426,6 +1441,21 @@ test("adds partial data and discards errors returned in incremental chunks with
14261441
}
14271442

14281443
subject.next(friends[0]);
1444+
1445+
{
1446+
const { snapshot, renderedComponents } = await takeRender();
1447+
1448+
expect(renderedComponents).toStrictEqual(["useSuspenseQuery"]);
1449+
expect(snapshot).toStrictEqualTyped({
1450+
data: markAsStreaming({
1451+
friendList: [{ __typename: "Friend", id: "1", name: "Luke" }],
1452+
}),
1453+
dataState: "streaming",
1454+
networkStatus: NetworkStatus.streaming,
1455+
error: undefined,
1456+
});
1457+
}
1458+
14291459
subject.next(new Error("Could not get friend"));
14301460

14311461
{
@@ -1503,6 +1533,21 @@ test("can refetch and respond to cache updates after encountering an error in an
15031533
}
15041534

15051535
subject.next(friends[0]);
1536+
1537+
{
1538+
const { snapshot, renderedComponents } = await takeRender();
1539+
1540+
expect(renderedComponents).toStrictEqual(["useSuspenseQuery"]);
1541+
expect(snapshot).toStrictEqualTyped({
1542+
data: markAsStreaming({
1543+
friendList: [{ __typename: "Friend", id: "1", name: "Luke" }],
1544+
}),
1545+
dataState: "streaming",
1546+
networkStatus: NetworkStatus.streaming,
1547+
error: undefined,
1548+
});
1549+
}
1550+
15061551
subject.next(new Error("Could not get friend"));
15071552

15081553
{

0 commit comments

Comments
 (0)