From 6a9297469a4067608b98980ff5e2f050c61a0aa2 Mon Sep 17 00:00:00 2001 From: Jack Pope Date: Thu, 7 Mar 2024 17:20:54 -0500 Subject: [PATCH 1/3] Concurrent rendering for ReactART-test --- .../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..287af5fc7ccf2 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(); @@ -73,6 +68,7 @@ describe('ReactART', () => { let container; beforeEach(() => { + jest.resetModules(); container = document.createElement('div'); document.body.appendChild(container); @@ -449,85 +445,136 @@ describe('ReactART', () => { }); describe('ReactARTComponents', () => { - it('should generate a with props for drawing the Circle', () => { - const circle = ReactTestRenderer.create( - , - ); + let ReactTestRenderer; + beforeEach(() => { + jest.resetModules(); + 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(); }); }); From bbd13ffd09c1ef42a3707744fa6db7c73c862a6d Mon Sep 17 00:00:00 2001 From: Jack Pope Date: Mon, 11 Mar 2024 16:02:09 -0400 Subject: [PATCH 2/3] f --- packages/react-art/src/__tests__/ReactART-test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/react-art/src/__tests__/ReactART-test.js b/packages/react-art/src/__tests__/ReactART-test.js index 287af5fc7ccf2..561b259374650 100644 --- a/packages/react-art/src/__tests__/ReactART-test.js +++ b/packages/react-art/src/__tests__/ReactART-test.js @@ -68,7 +68,6 @@ describe('ReactART', () => { let container; beforeEach(() => { - jest.resetModules(); container = document.createElement('div'); document.body.appendChild(container); From 525d5fd1355436d92cb0f5717727d6acd732df7e Mon Sep 17 00:00:00 2001 From: Jack Pope Date: Mon, 18 Mar 2024 15:32:44 -0400 Subject: [PATCH 3/3] Move comment --- packages/react-art/src/__tests__/ReactART-test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-art/src/__tests__/ReactART-test.js b/packages/react-art/src/__tests__/ReactART-test.js index 561b259374650..67b98d9d3e776 100644 --- a/packages/react-art/src/__tests__/ReactART-test.js +++ b/packages/react-art/src/__tests__/ReactART-test.js @@ -447,6 +447,7 @@ describe('ReactARTComponents', () => { let ReactTestRenderer; beforeEach(() => { jest.resetModules(); + // Isolate test renderer. ReactTestRenderer = require('react-test-renderer'); act = require('internal-test-utils').act; });