Test for ReactTestRenderer (#28674)

This is a repro for a breakage that #28672 would introduce for legacy
sync rendering.
This commit is contained in:
Jan Kassens
2024-03-29 14:01:45 -04:00
committed by GitHub
parent 18812b645c
commit 23b32d3f8d
@@ -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;