From bc13750bdf9ca29c7d23a71c5760c21a78cf3fc4 Mon Sep 17 00:00:00 2001 From: Jack Pope Date: Mon, 18 Mar 2024 15:40:02 -0400 Subject: [PATCH] Concurrent rendering for ReactART-test (#28521) ## Summary We need to unblock flipping the default for RTR to be concurrent rendering. Update ReactART-test to use `unstable_isConcurrent` in place. ## How did you test this change? `yarn test packages/react-art/src/__tests__/ReactART-test.js` --- .../react-art/src/__tests__/ReactART-test.js | 157 ++++++++++++------ 1 file changed, 102 insertions(+), 55 deletions(-) diff --git a/packages/react-art/src/__tests__/ReactART-test.js b/packages/react-art/src/__tests__/ReactART-test.js index 26ec23da95e16..67b98d9d3e776 100644 --- a/packages/react-art/src/__tests__/ReactART-test.js +++ b/packages/react-art/src/__tests__/ReactART-test.js @@ -24,13 +24,8 @@ import Wedge from 'react-art/Wedge'; // Isolate DOM renderer. jest.resetModules(); - const ReactDOMClient = require('react-dom/client'); -const act = require('internal-test-utils').act; - -// Isolate test renderer. -jest.resetModules(); -const ReactTestRenderer = require('react-test-renderer'); +let act = require('internal-test-utils').act; // Isolate the noop renderer jest.resetModules(); @@ -449,85 +444,137 @@ describe('ReactART', () => { }); describe('ReactARTComponents', () => { - it('should generate a with props for drawing the Circle', () => { - const circle = ReactTestRenderer.create( - , - ); + let ReactTestRenderer; + beforeEach(() => { + jest.resetModules(); + // Isolate test renderer. + ReactTestRenderer = require('react-test-renderer'); + act = require('internal-test-utils').act; + }); + + it('should generate a with props for drawing the Circle', async () => { + let circle; + await act(() => { + circle = ReactTestRenderer.create( + , + {unstable_isConcurrent: true}, + ); + }); expect(circle.toJSON()).toMatchSnapshot(); }); - it('should generate a with props for drawing the Rectangle', () => { - const rectangle = ReactTestRenderer.create( - , - ); + it('should generate a with props for drawing the Rectangle', async () => { + let rectangle; + await act(() => { + rectangle = ReactTestRenderer.create( + , + {unstable_isConcurrent: true}, + ); + }); expect(rectangle.toJSON()).toMatchSnapshot(); }); - it('should generate a with positive width when width prop is negative', () => { - const rectangle = ReactTestRenderer.create( - , - ); + it('should generate a with positive width when width prop is negative', async () => { + let rectangle; + await act(() => { + rectangle = ReactTestRenderer.create( + , + {unstable_isConcurrent: true}, + ); + }); expect(rectangle.toJSON()).toMatchSnapshot(); }); - it('should generate a with positive height when height prop is negative', () => { - const rectangle = ReactTestRenderer.create( - , - ); + it('should generate a with positive height when height prop is negative', async () => { + let rectangle; + await act(() => { + rectangle = ReactTestRenderer.create( + , + {unstable_isConcurrent: true}, + ); + }); expect(rectangle.toJSON()).toMatchSnapshot(); }); - it('should generate a with a radius property of 0 when top left radius prop is negative', () => { - const rectangle = ReactTestRenderer.create( - , - ); + it('should generate a with a radius property of 0 when top left radius prop is negative', async () => { + let rectangle; + await act(() => { + rectangle = ReactTestRenderer.create( + , + {unstable_isConcurrent: true}, + ); + }); expect(rectangle.toJSON()).toMatchSnapshot(); }); - it('should generate a with a radius property of 0 when top right radius prop is negative', () => { - const rectangle = ReactTestRenderer.create( - , - ); + it('should generate a with a radius property of 0 when top right radius prop is negative', async () => { + let rectangle; + await act(() => { + rectangle = ReactTestRenderer.create( + , + {unstable_isConcurrent: true}, + ); + }); expect(rectangle.toJSON()).toMatchSnapshot(); }); - it('should generate a with a radius property of 0 when bottom right radius prop is negative', () => { - const rectangle = ReactTestRenderer.create( - , - ); + it('should generate a with a radius property of 0 when bottom right radius prop is negative', async () => { + let rectangle; + await act(() => { + rectangle = ReactTestRenderer.create( + , + {unstable_isConcurrent: true}, + ); + }); expect(rectangle.toJSON()).toMatchSnapshot(); }); - it('should generate a with a radius property of 0 when bottom left radius prop is negative', () => { - const rectangle = ReactTestRenderer.create( - , - ); + it('should generate a with a radius property of 0 when bottom left radius prop is negative', async () => { + let rectangle; + await act(() => { + rectangle = ReactTestRenderer.create( + , + {unstable_isConcurrent: true}, + ); + }); expect(rectangle.toJSON()).toMatchSnapshot(); }); - it('should generate a where top radius is 0 if the sum of the top radius is greater than width', () => { - const rectangle = ReactTestRenderer.create( - , - ); + it('should generate a where top radius is 0 if the sum of the top radius is greater than width', async () => { + let rectangle; + await act(() => { + rectangle = ReactTestRenderer.create( + , + {unstable_isConcurrent: true}, + ); + }); expect(rectangle.toJSON()).toMatchSnapshot(); }); - it('should generate a with props for drawing the Wedge', () => { - const wedge = ReactTestRenderer.create( - , - ); + it('should generate a with props for drawing the Wedge', async () => { + let wedge; + await act(() => { + wedge = ReactTestRenderer.create( + , + {unstable_isConcurrent: true}, + ); + }); expect(wedge.toJSON()).toMatchSnapshot(); }); - it('should return null if startAngle equals to endAngle on Wedge', () => { - const wedge = ReactTestRenderer.create( - , - ); + it('should return null if startAngle equals to endAngle on Wedge', async () => { + let wedge; + await act(() => { + wedge = ReactTestRenderer.create( + , + {unstable_isConcurrent: true}, + ); + }); expect(wedge.toJSON()).toBeNull(); }); });