@samitouri / QOS-React-2 / commits / 23b32d3f8d

Test for ReactTestRenderer (#28674)

This is a repro for a breakage that #28672 would introduce for legacy sync rendering.

Jan Kassens committed Mar 29, 2024 at 14:01 UTC 23b32d3f8d273c87f114ad3ec2dcd44d16a5c624
1 file changed +29
packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js
+29
@@ -50,6 +50,35 @@ describe('ReactTestRenderer', () => {
50 expect(errors[1].message.includes('indexOf is not a function')).toBe(true);
51 });
52
53 + test('find element by prop with suspended content', async () => {
54 + const neverResolve = new Promise(() => {});
55 +
56 + function TestComp({foo}) {
57 + if (foo === 'one') {
58 + throw neverResolve;
59 + } else {
60 + return null;
61 + }
62 + }
63 +
64 + const tree = await act(() =>
65 + ReactTestRenderer.create(
66 + <div>
67 + <React.Suspense fallback={null}>
68 + <TestComp foo="one" />
69 + </React.Suspense>
70 + <TestComp foo="two" />
71 + </div>,
72 + ),
73 + );
74 +
75 + expect(
76 + tree.root.find(item => {
77 + return item.props.foo === 'two';
78 + }),
79 + ).toBeDefined();
80 + });
81 +
82 describe('timed out Suspense hidden subtrees should not be observable via toJSON', () => {
83 let AsyncText;
84 let PendingResources;