Skip to content

Commit

Permalink
remove renderToRenderStream
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Dec 3, 2024
1 parent 09240a7 commit 28b705e
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 52 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "6.4.6",
"@testing-library/react": "^16.0.1",
"@testing-library/react-render-stream": "https://pkg.pr.new/testing-library/react-render-stream-testing-library/@testing-library/react-render-stream@fab8705f2",
"@testing-library/react-render-stream": "https://pkg.pr.new/testing-library/react-render-stream-testing-library/@testing-library/react-render-stream@04c222de7",
"@testing-library/user-event": "14.5.2",
"@tsconfig/node20": "20.1.4",
"@types/bytes": "3.1.4",
Expand Down
6 changes: 4 additions & 2 deletions src/react/components/__tests__/client/Query.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Query } from "../../Query";
import { QueryResult } from "../../../types/types";
import {
disableActEnvironment,
renderToRenderStream,
createRenderStream,
} from "@testing-library/react-render-stream";

const allPeopleQuery: DocumentNode = gql`
Expand Down Expand Up @@ -1504,7 +1504,9 @@ describe("Query component", () => {
}

using _disabledAct = disableActEnvironment();
const { takeRender, replaceSnapshot } = renderToRenderStream<QueryResult>(
const { takeRender, replaceSnapshot, render } =
createRenderStream<QueryResult>();
await render(
<ApolloProvider client={client}>
<Container />
</ApolloProvider>
Expand Down
38 changes: 19 additions & 19 deletions src/react/components/__tests__/client/Subscription.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Subscription } from "../../Subscription";
import { spyOnConsole } from "../../../../testing/internal";
import {
disableActEnvironment,
renderToRenderStream,
createRenderStream,
} from "@testing-library/react-render-stream";

const results = [
Expand Down Expand Up @@ -439,13 +439,12 @@ describe("should update", () => {
);
}
using _disabledAct = disableActEnvironment();
const { takeRender, replaceSnapshot, renderResultPromise } =
renderToRenderStream<any>(
<ApolloProvider client={client}>
<Container />
</ApolloProvider>
);
const { rerender } = await renderResultPromise;
const { takeRender, replaceSnapshot, render } = createRenderStream<any>();
const { rerender } = await render(
<ApolloProvider client={client}>
<Container />
</ApolloProvider>
);
{
const {
snapshot: { loading, data },
Expand Down Expand Up @@ -537,13 +536,15 @@ describe("should update", () => {
}

using _disabledAct = disableActEnvironment();
const { takeRender, replaceSnapshot, renderResultPromise } =
renderToRenderStream<any>(<Container subscription={subscription} />, {
const { takeRender, replaceSnapshot, render } = createRenderStream<any>();
const { rerender } = await render(
<Container subscription={subscription} />,
{
wrapper: ({ children }) => (
<ApolloProvider client={mockClient}>{children}</ApolloProvider>
),
});
const { rerender } = await renderResultPromise;
}
);

{
const {
Expand Down Expand Up @@ -631,13 +632,12 @@ describe("should update", () => {
);
}
using _disabledAct = disableActEnvironment();
const { takeRender, renderResultPromise, replaceSnapshot } =
renderToRenderStream<any>(<Container variables={variablesLuke} />, {
wrapper: ({ children }) => (
<ApolloProvider client={mockClient}>{children}</ApolloProvider>
),
});
const { rerender } = await renderResultPromise;
const { takeRender, render, replaceSnapshot } = createRenderStream<any>();
const { rerender } = await render(<Container variables={variablesLuke} />, {
wrapper: ({ children }) => (
<ApolloProvider client={mockClient}>{children}</ApolloProvider>
),
});

{
const {
Expand Down
16 changes: 8 additions & 8 deletions src/react/hoc/__tests__/queries/lifecycle.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { graphql } from "../../graphql";
import { ChildProps, DataValue } from "../../types";
import {
disableActEnvironment,
renderToRenderStream,
createRenderStream,
} from "@testing-library/react-render-stream";

describe("[queries] lifecycle", () => {
Expand Down Expand Up @@ -62,13 +62,13 @@ describe("[queries] lifecycle", () => {
);

using _disabledAct = disableActEnvironment();
const { takeRender, replaceSnapshot, renderResultPromise } =
renderToRenderStream<DataValue<Data, Vars>>(<Container first={1} />, {
wrapper: ({ children }) => (
<ApolloProvider client={client}>{children}</ApolloProvider>
),
});
const { rerender } = await renderResultPromise;
const { takeRender, replaceSnapshot, render } =
createRenderStream<DataValue<Data, Vars>>();
const { rerender } = await render(<Container first={1} />, {
wrapper: ({ children }) => (
<ApolloProvider client={client}>{children}</ApolloProvider>
),
});

{
const { snapshot } = await takeRender();
Expand Down
33 changes: 18 additions & 15 deletions src/react/hooks/__tests__/useFragment.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { SubscriptionObserver } from "zen-observable-ts";
import {
disableActEnvironment,
renderHookToSnapshotStream,
renderToRenderStream,
createRenderStream,
} from "@testing-library/react-render-stream";
import { spyOnConsole } from "../../../testing/internal";

Expand Down Expand Up @@ -1807,18 +1807,17 @@ describe("has the same timing as `useQuery`", () => {
}

using _disabledAct = disableActEnvironment();
const { takeRender, replaceSnapshot } = renderToRenderStream(
<Component />,
{
initialSnapshot: {
queryData: undefined as any,
fragmentData: undefined as any,
},
wrapper: ({ children }) => (
<ApolloProvider client={client}>{children}</ApolloProvider>
),
}
);
const { takeRender, replaceSnapshot, render } = createRenderStream({
initialSnapshot: {
queryData: undefined as any,
fragmentData: undefined as any,
},
});
await render(<Component />, {
wrapper: ({ children }) => (
<ApolloProvider client={client}>{children}</ApolloProvider>
),
});

{
const { snapshot } = await takeRender();
Expand Down Expand Up @@ -1889,7 +1888,7 @@ describe("has the same timing as `useQuery`", () => {
}

using _disabledAct = disableActEnvironment();
const { takeRender } = renderToRenderStream(<Parent />, {
const { takeRender, render } = createRenderStream({
snapshotDOM: true,
onRender() {
const parent = screen.getByTestId("parent");
Expand All @@ -1901,6 +1900,8 @@ describe("has the same timing as `useQuery`", () => {
within(children).queryAllByText(/Item #2/).length
);
},
});
await render(<Parent />, {
wrapper: ({ children }) => (
<ApolloProvider client={client}>{children}</ApolloProvider>
),
Expand Down Expand Up @@ -1981,7 +1982,7 @@ describe("has the same timing as `useQuery`", () => {
}

using _disabledAct = disableActEnvironment();
const { takeRender } = renderToRenderStream(<Parent />, {
const { takeRender, render } = createRenderStream({
onRender() {
const parent = screen.getByTestId("parent");
const children = screen.getByTestId("children");
Expand All @@ -1992,6 +1993,8 @@ describe("has the same timing as `useQuery`", () => {
within(children).queryAllByText(/Item #2/).length
);
},
});
await render(<Parent />, {
wrapper: ({ children }) => (
<ApolloProvider client={client}>{children}</ApolloProvider>
),
Expand Down
10 changes: 6 additions & 4 deletions src/react/hooks/__tests__/useSuspenseQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ import {
import {
createRenderStream,
disableActEnvironment,
renderToRenderStream,
useTrackRenders,
} from "@testing-library/react-render-stream";

Expand Down Expand Up @@ -401,10 +400,12 @@ describe("useSuspenseQuery", () => {
});

using _disabledAct = disableActEnvironment();
const { takeRender, replaceSnapshot } = await renderToRenderStream<
const { takeRender, replaceSnapshot, render } = await createRenderStream<
UseSuspenseQueryResult<SimpleQueryData, OperationVariables>
>(<App />, {
>({
snapshotDOM: true,
});
await render(<App />, {
wrapper: ({ children }) => (
<ApolloProvider client={client}>{children}</ApolloProvider>
),
Expand Down Expand Up @@ -9792,9 +9793,10 @@ describe("useSuspenseQuery", () => {
}

using _disabledAct = disableActEnvironment();
const { takeRender } = await renderToRenderStream(<App />, {
const { takeRender, render } = await createRenderStream({
snapshotDOM: true,
});
await render(<App />);

{
const { withinDOM } = await takeRender();
Expand Down

0 comments on commit 28b705e

Please sign in to comment.