Skip to content
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