Skip to content

Commit

Permalink
Test for ReactTestRenderer (facebook#28674)
Browse files Browse the repository at this point in the history
This is a repro for a breakage that facebook#28672 would introduce for legacy
sync rendering.
  • Loading branch information
kassens authored and AndyPengc12 committed Apr 15, 2024
1 parent e74b3f9 commit bf31d2b
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,35 @@ describe('ReactTestRenderer', () => {
expect(errors[1].message.includes('indexOf is not a function')).toBe(true);
});

test('find element by prop with suspended content', async () => {
const neverResolve = new Promise(() => {});

function TestComp({foo}) {
if (foo === 'one') {
throw neverResolve;
} else {
return null;
}
}

const tree = await act(() =>
ReactTestRenderer.create(
<div>
<React.Suspense fallback={null}>
<TestComp foo="one" />
</React.Suspense>
<TestComp foo="two" />
</div>,
),
);

expect(
tree.root.find(item => {
return item.props.foo === 'two';
}),
).toBeDefined();
});

describe('timed out Suspense hidden subtrees should not be observable via toJSON', () => {
let AsyncText;
let PendingResources;
Expand Down

0 comments on commit bf31d2b

Please sign in to comment.