Skip to content

Commit

Permalink
fix up async calls
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Nov 28, 2024
1 parent 670eafe commit 3f1a659
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/react/hooks/__tests__/useSubscription.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ followed by new in-flight setup", async () => {
});

describe("errorPolicy", () => {
function setup(
async function setup(
initialProps: SubscriptionHookOptions<{ totalLikes: number }, {}>
) {
const subscription: TypedDocumentNode<{ totalLikes: number }, {}> = gql`
Expand All @@ -1217,7 +1217,7 @@ followed by new in-flight setup", async () => {
</ErrorBoundary>
</ApolloProvider>
);
const { takeSnapshot } = renderHookToSnapshotStream(
const { takeSnapshot } = await renderHookToSnapshotStream(
(options: SubscriptionHookOptions<{ totalLikes: number }, {}>) =>
useSubscription(subscription, options),
{
Expand Down Expand Up @@ -1254,7 +1254,7 @@ followed by new in-flight setup", async () => {
link,
graphQlErrorResult,
errorBoundaryOnError,
} = setup({ errorPolicy, onError, onData });
} = await setup({ errorPolicy, onError, onData });

await takeSnapshot();
link.simulateResult(graphQlErrorResult);
Expand Down Expand Up @@ -1287,7 +1287,7 @@ followed by new in-flight setup", async () => {
const onData = jest.fn();
const onError = jest.fn();
const { takeSnapshot, link, graphQlErrorResult, errorBoundaryOnError } =
setup({ errorPolicy: "all", onError, onData });
await setup({ errorPolicy: "all", onError, onData });

await takeSnapshot();
link.simulateResult(graphQlErrorResult);
Expand Down Expand Up @@ -1321,7 +1321,7 @@ followed by new in-flight setup", async () => {
const onData = jest.fn();
const onError = jest.fn();
const { takeSnapshot, link, graphQlErrorResult, errorBoundaryOnError } =
setup({
await setup({
errorPolicy: "ignore",
onError,
onData,
Expand Down Expand Up @@ -1366,7 +1366,7 @@ followed by new in-flight setup", async () => {
link,
protocolErrorResult,
errorBoundaryOnError,
} = setup({ errorPolicy, onError, onData });
} = await setup({ errorPolicy, onError, onData });

await takeSnapshot();
link.simulateResult(protocolErrorResult);
Expand Down Expand Up @@ -1400,7 +1400,7 @@ followed by new in-flight setup", async () => {
});

describe("`restart` callback", () => {
function setup(
async function setup(
initialProps: SubscriptionHookOptions<
{ totalLikes: number },
{ id: string }
Expand All @@ -1424,7 +1424,7 @@ describe("`restart` callback", () => {
cache: new Cache(),
});
const { takeSnapshot, getCurrentSnapshot, rerender } =
renderHookToSnapshotStream(
await renderHookToSnapshotStream(
(
options: SubscriptionHookOptions<
{ totalLikes: number },
Expand Down Expand Up @@ -1455,7 +1455,7 @@ describe("`restart` callback", () => {
getCurrentSnapshot,
onSubscribe,
onUnsubscribe,
} = setup({
} = await setup({
variables: { id: "1" },
});

Expand Down Expand Up @@ -1519,7 +1519,7 @@ describe("`restart` callback", () => {
onSubscribe,
onUnsubscribe,
rerender,
} = setup({
} = await setup({
variables: { id: "1" },
});
{
Expand Down Expand Up @@ -1616,7 +1616,7 @@ describe("`restart` callback", () => {
getCurrentSnapshot,
onSubscribe,
onUnsubscribe,
} = setup({
} = await setup({
variables: { id: "1" },
});
{
Expand Down Expand Up @@ -1678,7 +1678,7 @@ describe("`restart` callback", () => {
getCurrentSnapshot,
onSubscribe,
onUnsubscribe,
} = setup({
} = await setup({
variables: { id: "1" },
});
{
Expand Down Expand Up @@ -1738,7 +1738,7 @@ describe("`restart` callback", () => {
});
it("will not restart a subscription that has been `skip`ped", async () => {
const { takeSnapshot, getCurrentSnapshot, onSubscribe, onUnsubscribe } =
setup({
await setup({
variables: { id: "1" },
skip: true,
});
Expand Down Expand Up @@ -1790,7 +1790,7 @@ describe("ignoreResults", () => {
const onComplete = jest.fn(
(() => {}) as SubscriptionHookOptions["onComplete"]
);
const { takeSnapshot } = renderHookToSnapshotStream(
const { takeSnapshot } = await renderHookToSnapshotStream(
() =>
useSubscription(subscription, {
ignoreResults: true,
Expand Down Expand Up @@ -1863,7 +1863,7 @@ describe("ignoreResults", () => {
const onComplete = jest.fn(
(() => {}) as SubscriptionHookOptions["onComplete"]
);
const { takeSnapshot } = renderHookToSnapshotStream(
const { takeSnapshot } = await renderHookToSnapshotStream(
() =>
useSubscription(subscription, {
ignoreResults: true,
Expand Down Expand Up @@ -1928,7 +1928,7 @@ describe("ignoreResults", () => {
});

const onData = jest.fn((() => {}) as SubscriptionHookOptions["onData"]);
const { takeSnapshot, rerender } = renderHookToSnapshotStream(
const { takeSnapshot, rerender } = await renderHookToSnapshotStream(
({ ignoreResults }: { ignoreResults: boolean }) =>
useSubscription(subscription, {
ignoreResults,
Expand Down Expand Up @@ -1998,7 +1998,7 @@ describe("ignoreResults", () => {
});

const onData = jest.fn((() => {}) as SubscriptionHookOptions["onData"]);
const { takeSnapshot, rerender } = renderHookToSnapshotStream(
const { takeSnapshot, rerender } = await renderHookToSnapshotStream(
({ ignoreResults }: { ignoreResults: boolean }) =>
useSubscription(subscription, {
ignoreResults,
Expand Down

0 comments on commit 3f1a659

Please sign in to comment.