@samitouri / QOS-React-1 / commits / 09c0769448

chore: use versioned render in console test (#28213)

Ruslan Lesiutin committed Feb 5, 2024 at 17:12 UTC 09c0769448655deaf69e2bf65eecc74268fda02a
1 file changed +13 -15
packages/react-devtools-shared/src/__tests__/console-test.js
+13 -15
@@ -7,13 +7,12 @@
7 * @flow
8 */
9
10 -import {normalizeCodeLocInfo} from './utils';
10 +import {getVersionedRenderImplementation, normalizeCodeLocInfo} from './utils';
11
12 let React;
13 let ReactDOMClient;
14 let act;
15 let fakeConsole;
16 -let legacyRender;
16 let mockError;
17 let mockInfo;
18 let mockGroup;
@@ -67,9 +66,10 @@ describe('console', () => {
66
67 const utils = require('./utils');
68 act = utils.act;
70 - legacyRender = utils.legacyRender;
69 });
70
71 + const {render} = getVersionedRenderImplementation();
72 +
73 // @reactVersion >=18.0
74 it('should not patch console methods that are not explicitly overridden', () => {
75 expect(fakeConsole.error).not.toBe(mockError);
@@ -185,7 +185,7 @@ describe('console', () => {
185 return null;
186 };
187
188 - act(() => legacyRender(<Child />, document.createElement('div')));
188 + act(() => render(<Child />));
189
190 expect(mockWarn).toHaveBeenCalledTimes(1);
191 expect(mockWarn.mock.calls[0]).toHaveLength(1);
@@ -215,7 +215,7 @@ describe('console', () => {
215 return null;
216 };
217
218 - act(() => legacyRender(<Parent />, document.createElement('div')));
218 + act(() => render(<Parent />));
219
220 expect(mockLog).toHaveBeenCalledTimes(1);
221 expect(mockLog.mock.calls[0]).toHaveLength(1);
@@ -256,7 +256,7 @@ describe('console', () => {
256 return null;
257 };
258
259 - act(() => legacyRender(<Parent />, document.createElement('div')));
259 + act(() => render(<Parent />));
260
261 expect(mockLog).toHaveBeenCalledTimes(2);
262 expect(mockLog.mock.calls[0]).toHaveLength(1);
@@ -313,9 +313,8 @@ describe('console', () => {
313 }
314 }
315
316 - const container = document.createElement('div');
317 - act(() => legacyRender(<Parent />, container));
318 - act(() => legacyRender(<Parent />, container));
316 + act(() => render(<Parent />));
317 + act(() => render(<Parent />));
318
319 expect(mockLog).toHaveBeenCalledTimes(2);
320 expect(mockLog.mock.calls[0]).toHaveLength(1);
@@ -367,7 +366,7 @@ describe('console', () => {
366 }
367 }
368
370 - act(() => legacyRender(<Parent />, document.createElement('div')));
369 + act(() => render(<Parent />));
370
371 expect(mockLog).toHaveBeenCalledTimes(1);
372 expect(mockLog.mock.calls[0]).toHaveLength(1);
@@ -396,7 +395,7 @@ describe('console', () => {
395 return null;
396 };
397
399 - act(() => legacyRender(<Child />, document.createElement('div')));
398 + act(() => render(<Child />));
399
400 expect(mockWarn).toHaveBeenCalledTimes(1);
401 expect(mockWarn.mock.calls[0]).toHaveLength(1);
@@ -410,7 +409,7 @@ describe('console', () => {
409 breakOnConsoleErrors: false,
410 showInlineWarningsAndErrors: false,
411 });
413 - act(() => legacyRender(<Child />, document.createElement('div')));
412 + act(() => render(<Child />));
413
414 expect(mockWarn).toHaveBeenCalledTimes(2);
415 expect(mockWarn.mock.calls[1]).toHaveLength(2);
@@ -457,7 +456,7 @@ describe('console', () => {
456 return null;
457 };
458
460 - act(() => legacyRender(<Parent />, document.createElement('div')));
459 + act(() => render(<Parent />));
460
461 expect(mockLog).toHaveBeenCalledTimes(1);
462 expect(mockLog.mock.calls[0]).toHaveLength(1);
@@ -483,7 +482,7 @@ describe('console', () => {
482 return null;
483 };
484
486 - act(() => legacyRender(<Component />, document.createElement('div')));
485 + act(() => render(<Component />));
486
487 expect(mockWarn).toHaveBeenCalledTimes(1);
488 expect(mockWarn.mock.calls[0][0]).toBe('Symbol:');
@@ -824,7 +823,6 @@ describe('console error', () => {
823
824 const utils = require('./utils');
825 act = utils.act;
827 - legacyRender = utils.legacyRender;
826 });
827
828 // @reactVersion >=18.0