Skip to content

Commit

Permalink
Use createRoot in ReactMockedComponent-test (#28087)
Browse files Browse the repository at this point in the history
Co-authored-by: Jack Pope <jackpope@meta.com>
  • Loading branch information
jackpope and Jack Pope committed Jan 26, 2024
1 parent 4c41c09 commit 54f2314
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 54f2314

Please sign in to comment.