Skip to content

Commit

Permalink
Use createRoot in ReactMockedComponent-test (facebook#28087)
Browse files Browse the repository at this point in the history
Co-authored-by: Jack Pope <jackpope@meta.com>
  • Loading branch information
2 people authored and AndyPengc12 committed Apr 15, 2024
1 parent 6f857fd commit 5919068
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions packages/react-dom/src/__tests__/ReactMockedComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
'use strict';

let React;
let ReactDOM;
let ReactDOMClient;
let act;

let MockedComponent;
let ReactDOMServer;

describe('ReactMockedComponent', () => {
beforeEach(() => {
React = require('react');
ReactDOM = require('react-dom');
ReactDOMClient = require('react-dom/client');
ReactDOMServer = require('react-dom/server');
act = require('internal-test-utils').act;

MockedComponent = class extends React.Component {
render() {
Expand All @@ -30,15 +32,23 @@ describe('ReactMockedComponent', () => {
MockedComponent.prototype.render = jest.fn();
});

it('should allow a mocked component to be rendered', () => {
it('should allow a mocked component to be rendered', async () => {
const container = document.createElement('container');
ReactDOM.render(<MockedComponent />, container);
const root = ReactDOMClient.createRoot(container);
await act(() => {
root.render(<MockedComponent />);
});
});

it('should allow a mocked component to be updated in dev', () => {
it('should allow a mocked component to be updated in dev', async () => {
const container = document.createElement('container');
ReactDOM.render(<MockedComponent />, container);
ReactDOM.render(<MockedComponent />, container);
const root = ReactDOMClient.createRoot(container);
await act(() => {
root.render(<MockedComponent />);
});
await act(() => {
root.render(<MockedComponent />);
});
});

it('should allow a mocked component to be rendered in dev (SSR)', () => {
Expand Down

0 comments on commit 5919068

Please sign in to comment.