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(); }); });