@samitouri / QOS-React-1 / commits / e68431c89f

Remove ReactTestUtils from ReactJSXTransformIntegration (#28338)

Sebastian Silbermann committed Feb 20, 2024 at 16:50 UTC e68431c89fe7ed36f7eac4f607a9d4836d3788fd
1 file changed +19 -9
packages/react/src/__tests__/ReactJSXTransformIntegration-test.js
+19 -9
@@ -11,7 +11,6 @@
11
12 let React;
13 let ReactDOMClient;
14 -let ReactTestUtils;
14 let act;
15
16 // TODO: Historically this module was used to confirm that the JSX transform
@@ -30,7 +29,6 @@ describe('ReactJSXTransformIntegration', () => {
29
30 React = require('react');
31 ReactDOMClient = require('react-dom/client');
33 - ReactTestUtils = require('react-dom/test-utils');
32 act = require('internal-test-utils').act;
33
34 Component = class extends React.Component {
@@ -213,7 +211,7 @@ describe('ReactJSXTransformIntegration', () => {
211 expect(instance.props.fruit).toBe('persimmon');
212 });
213
216 - it('should normalize props with default values', () => {
214 + it('should normalize props with default values', async () => {
215 class NormalizingComponent extends React.Component {
216 render() {
217 return <span>{this.props.prop}</span>;
@@ -221,14 +219,26 @@ describe('ReactJSXTransformIntegration', () => {
219 }
220 NormalizingComponent.defaultProps = {prop: 'testKey'};
221
224 - const instance = ReactTestUtils.renderIntoDocument(
225 - <NormalizingComponent />,
226 - );
222 + let container = document.createElement('div');
223 + let root = ReactDOMClient.createRoot(container);
224 + let instance;
225 + await act(() => {
226 + root.render(
227 + <NormalizingComponent ref={current => (instance = current)} />,
228 + );
229 + });
230 +
231 expect(instance.props.prop).toBe('testKey');
232
229 - const inst2 = ReactTestUtils.renderIntoDocument(
230 - <NormalizingComponent prop={null} />,
231 - );
233 + container = document.createElement('div');
234 + root = ReactDOMClient.createRoot(container);
235 + let inst2;
236 + await act(() => {
237 + root.render(
238 + <NormalizingComponent prop={null} ref={current => (inst2 = current)} />,
239 + );
240 + });
241 +
242 expect(inst2.props.prop).toBe(null);
243 });
244 });