Skip to content

Commit

Permalink
Remove ReactTestUtils from ReactJSXTransformIntegration
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Silbermann committed Feb 14, 2024
1 parent adadb81 commit f1ab7e6
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions packages/react/src/__tests__/ReactJSXTransformIntegration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

let React;
let ReactDOMClient;
let ReactTestUtils;
let act;

// TODO: Historically this module was used to confirm that the JSX transform
Expand All @@ -30,7 +29,6 @@ describe('ReactJSXTransformIntegration', () => {

React = require('react');
ReactDOMClient = require('react-dom/client');
ReactTestUtils = require('react-dom/test-utils');
act = require('internal-test-utils').act;

Component = class extends React.Component {
Expand Down Expand Up @@ -213,22 +211,34 @@ describe('ReactJSXTransformIntegration', () => {
expect(instance.props.fruit).toBe('persimmon');
});

it('should normalize props with default values', () => {
it('should normalize props with default values', async () => {
class NormalizingComponent extends React.Component {
render() {
return <span>{this.props.prop}</span>;
}
}
NormalizingComponent.defaultProps = {prop: 'testKey'};

const instance = ReactTestUtils.renderIntoDocument(
<NormalizingComponent />,
);
let container = document.createElement('div');
let root = ReactDOMClient.createRoot(container);
let instance;
await act(() => {
root.render(
<NormalizingComponent ref={current => (instance = current)} />,
);
});

expect(instance.props.prop).toBe('testKey');

const inst2 = ReactTestUtils.renderIntoDocument(
<NormalizingComponent prop={null} />,
);
container = document.createElement('div');
root = ReactDOMClient.createRoot(container);
let inst2;
await act(() => {
root.render(
<NormalizingComponent prop={null} ref={current => (inst2 = current)} />,
);
});

expect(inst2.props.prop).toBe(null);
});
});

0 comments on commit f1ab7e6

Please sign in to comment.