Skip to content

Commit

Permalink
Remove RTR from ReactCreateRef-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Pope committed Feb 20, 2024
1 parent a515d75 commit 0d6f12a
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions packages/react/src/__tests__/ReactCreateRef-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
'use strict';

let React;
let ReactTestRenderer;
let ReactDOM;
let ReactDOMClient;

describe('ReactCreateRef', () => {
beforeEach(() => {
jest.resetModules();

React = require('react');
ReactTestRenderer = require('react-test-renderer');
ReactDOM = require('react-dom');
ReactDOMClient = require('react-dom/client');
});

it('should warn in dev if an invalid ref object is provided', () => {
Expand All @@ -31,12 +33,15 @@ describe('ReactCreateRef', () => {
}
}

const root = ReactDOMClient.createRoot(document.createElement('div'));
expect(() =>
ReactTestRenderer.create(
<Wrapper>
<div ref={{}} />
</Wrapper>,
),
ReactDOM.flushSync(() => {
root.render(
<Wrapper>
<div ref={{}} />
</Wrapper>,
);
}),
).toErrorDev(
'Unexpected ref object provided for div. ' +
'Use either a ref-setter function or React.createRef().\n' +
Expand All @@ -45,11 +50,13 @@ describe('ReactCreateRef', () => {
);

expect(() =>
ReactTestRenderer.create(
<Wrapper>
<ExampleComponent ref={{}} />
</Wrapper>,
),
ReactDOM.flushSync(() => {
root.render(
<Wrapper>
<ExampleComponent ref={{}} />
</Wrapper>,
);
}),
).toErrorDev(
'Unexpected ref object provided for ExampleComponent. ' +
'Use either a ref-setter function or React.createRef().\n' +
Expand Down

0 comments on commit 0d6f12a

Please sign in to comment.