Skip to content

Commit 881f0d6

Browse files
committed
Fix ref forwarding test
1 parent 1923336 commit 881f0d6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/lazy.test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('lazy', () => {
4444
});
4545

4646
it('should forward refs', async () => {
47-
const A = () => <h1>A</h1>;
47+
const A = (props) => <h1 ref={props.ref}>A</h1>;
4848
const LazyA = lazy(() => Promise.resolve(A));
4949

5050
const ref = {};
@@ -57,6 +57,11 @@ describe('lazy', () => {
5757
);
5858
await new Promise(r => setTimeout(r, 1))
5959

60-
expect(ref.current.constructor).to.equal(A);
60+
if (ref.current instanceof A) {
61+
expect(ref.current.constructor).to.equal(A);
62+
} else {
63+
expect(ref.current).to.equal(scratch.firstChild);
64+
}
6165
});
6266
});
67+

0 commit comments

Comments
 (0)