Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use createRoot in ReactMockedComponent-test #28087

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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