Skip to content

Commit

Permalink
Convert ReactCompositeComponentNestedState to createRoot
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Jan 24, 2024
1 parent 4217d32 commit f6429c0
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
'use strict';

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

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

it('should provide up to date values for props', () => {
it('should provide up to date values for props', async () => {
class ParentComponent extends React.Component {
state = {color: 'blue'};

Expand Down Expand Up @@ -96,11 +98,16 @@ describe('ReactCompositeComponentNestedState-state', () => {
document.body.appendChild(container);

const logger = jest.fn();
const root = ReactDOMClient.createRoot(container);

void ReactDOM.render(<ParentComponent logger={logger} />, container);
await act(async () => {
root.render(<ParentComponent logger={logger} />);
});

// click "light green"
container.childNodes[0].childNodes[3].click();
await act(async () => {
// click "light green"
container.childNodes[0].childNodes[3].click();
});

expect(logger.mock.calls).toEqual([
['parent-render', 'blue'],
Expand Down

0 comments on commit f6429c0

Please sign in to comment.