Skip to content

Commit

Permalink
chore: use versioned render in componentStacks test (facebook#28214)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxyq authored and AndyPengc12 committed Apr 15, 2024
1 parent 4db971a commit 834ff68
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
* @flow
*/

import {normalizeCodeLocInfo} from './utils';
import {getVersionedRenderImplementation, normalizeCodeLocInfo} from './utils';

describe('component stack', () => {
let React;
let act;
let legacyRender;
let mockError;
let mockWarn;

Expand All @@ -30,11 +29,12 @@ describe('component stack', () => {

const utils = require('./utils');
act = utils.act;
legacyRender = utils.legacyRender;

React = require('react');
});

const {render} = getVersionedRenderImplementation();

// @reactVersion >=16.9
it('should log the current component stack along with an error or warning', () => {
const Grandparent = () => <Parent />;
Expand All @@ -45,9 +45,7 @@ describe('component stack', () => {
return null;
};

const container = document.createElement('div');

act(() => legacyRender(<Grandparent />, container));
act(() => render(<Grandparent />));

expect(mockError).toHaveBeenCalledWith(
'Test error.',
Expand Down Expand Up @@ -79,8 +77,7 @@ describe('component stack', () => {
return null;
};

const container = document.createElement('div');
act(() => legacyRender(<Example test="abc" />, container));
act(() => render(<Example test="abc" />));

expect(useEffectCount).toBe(1);

Expand Down

0 comments on commit 834ff68

Please sign in to comment.