@@ -24,13 +24,8 @@ import Wedge from 'react-art/Wedge';
2424
2525// Isolate DOM renderer.
2626jest . resetModules ( ) ;
27-
2827const ReactDOMClient = require ( 'react-dom/client' ) ;
29- const act = require ( 'internal-test-utils' ) . act ;
30-
31- // Isolate test renderer.
32- jest . resetModules ( ) ;
33- const ReactTestRenderer = require ( 'react-test-renderer' ) ;
28+ let act = require ( 'internal-test-utils' ) . act ;
3429
3530// Isolate the noop renderer
3631jest . resetModules ( ) ;
@@ -45,8 +40,16 @@ let TestComponent;
4540let waitFor ;
4641let groupRef ;
4742
43+ // let ReactDOMClient;
44+ // let ReactTestRenderer
45+ // let ReactNoop
46+ // let Scheduler
47+ // let act;
48+
4849const Missing = { } ;
4950
51+ // function setup()
52+
5053function testDOMNodeStructure ( domNode , expectedStructure ) {
5154 expect ( domNode ) . toBeDefined ( ) ;
5255 expect ( domNode . nodeName ) . toBe ( expectedStructure . nodeName ) ;
@@ -73,6 +76,7 @@ describe('ReactART', () => {
7376 let container ;
7477
7578 beforeEach ( ( ) => {
79+ jest . resetModules ( ) ;
7680 container = document . createElement ( 'div' ) ;
7781 document . body . appendChild ( container ) ;
7882
@@ -449,85 +453,125 @@ describe('ReactART', () => {
449453} ) ;
450454
451455describe ( 'ReactARTComponents' , ( ) => {
452- it ( 'should generate a <Shape> with props for drawing the Circle' , ( ) => {
453- const circle = ReactTestRenderer . create (
454- < Circle radius = { 10 } stroke = "green" strokeWidth = { 3 } fill = "blue" /> ,
455- ) ;
456+ let ReactTestRenderer ;
457+ beforeEach ( ( ) => {
458+ jest . resetModules ( ) ;
459+ ReactTestRenderer = require ( 'react-test-renderer' ) ;
460+ act = require ( 'internal-test-utils' ) . act ;
461+ } ) ;
462+
463+ it ( 'should generate a <Shape> with props for drawing the Circle' , async ( ) => {
464+ let circle ;
465+ await act ( ( ) => {
466+ circle = ReactTestRenderer . create (
467+ < Circle radius = { 10 } stroke = "green" strokeWidth = { 3 } fill = "blue" /> ,
468+ ) ;
469+ } ) ;
456470 expect ( circle . toJSON ( ) ) . toMatchSnapshot ( ) ;
457471 } ) ;
458472
459- it ( 'should generate a <Shape> with props for drawing the Rectangle' , ( ) => {
460- const rectangle = ReactTestRenderer . create (
461- < Rectangle width = { 50 } height = { 50 } stroke = "green" fill = "blue" /> ,
462- ) ;
473+ it ( 'should generate a <Shape> with props for drawing the Rectangle' , async ( ) => {
474+ let rectangle ;
475+ await act ( ( ) => {
476+ rectangle = ReactTestRenderer . create (
477+ < Rectangle width = { 50 } height = { 50 } stroke = "green" fill = "blue" /> ,
478+ ) ;
479+ } ) ;
463480 expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
464481 } ) ;
465482
466- it ( 'should generate a <Shape> with positive width when width prop is negative' , ( ) => {
467- const rectangle = ReactTestRenderer . create (
468- < Rectangle width = { - 50 } height = { 50 } /> ,
469- ) ;
483+ it ( 'should generate a <Shape> with positive width when width prop is negative' , async ( ) => {
484+ let rectangle ;
485+ await act ( ( ) => {
486+ rectangle = ReactTestRenderer . create (
487+ < Rectangle width = { - 50 } height = { 50 } /> ,
488+ ) ;
489+ } ) ;
470490 expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
471491 } ) ;
472492
473- it ( 'should generate a <Shape> with positive height when height prop is negative' , ( ) => {
474- const rectangle = ReactTestRenderer . create (
475- < Rectangle height = { - 50 } width = { 50 } /> ,
476- ) ;
493+ it ( 'should generate a <Shape> with positive height when height prop is negative' , async ( ) => {
494+ let rectangle ;
495+ await act ( ( ) => {
496+ rectangle = ReactTestRenderer . create (
497+ < Rectangle height = { - 50 } width = { 50 } /> ,
498+ ) ;
499+ } ) ;
477500 expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
478501 } ) ;
479502
480- it ( 'should generate a <Shape> with a radius property of 0 when top left radius prop is negative' , ( ) => {
481- const rectangle = ReactTestRenderer . create (
482- < Rectangle radiusTopLeft = { - 25 } width = { 50 } height = { 50 } /> ,
483- ) ;
503+ it ( 'should generate a <Shape> with a radius property of 0 when top left radius prop is negative' , async ( ) => {
504+ let rectangle ;
505+ await act ( ( ) => {
506+ rectangle = ReactTestRenderer . create (
507+ < Rectangle radiusTopLeft = { - 25 } width = { 50 } height = { 50 } /> ,
508+ ) ;
509+ } ) ;
484510 expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
485511 } ) ;
486512
487- it ( 'should generate a <Shape> with a radius property of 0 when top right radius prop is negative' , ( ) => {
488- const rectangle = ReactTestRenderer . create (
489- < Rectangle radiusTopRight = { - 25 } width = { 50 } height = { 50 } /> ,
490- ) ;
513+ it ( 'should generate a <Shape> with a radius property of 0 when top right radius prop is negative' , async ( ) => {
514+ let rectangle ;
515+ await act ( ( ) => {
516+ rectangle = ReactTestRenderer . create (
517+ < Rectangle radiusTopRight = { - 25 } width = { 50 } height = { 50 } /> ,
518+ ) ;
519+ } ) ;
491520 expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
492521 } ) ;
493522
494- it ( 'should generate a <Shape> with a radius property of 0 when bottom right radius prop is negative' , ( ) => {
495- const rectangle = ReactTestRenderer . create (
496- < Rectangle radiusBottomRight = { - 30 } width = { 50 } height = { 50 } /> ,
497- ) ;
523+ it ( 'should generate a <Shape> with a radius property of 0 when bottom right radius prop is negative' , async ( ) => {
524+ let rectangle ;
525+ await act ( ( ) => {
526+ rectangle = ReactTestRenderer . create (
527+ < Rectangle radiusBottomRight = { - 30 } width = { 50 } height = { 50 } /> ,
528+ ) ;
529+ } ) ;
498530 expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
499531 } ) ;
500532
501- it ( 'should generate a <Shape> with a radius property of 0 when bottom left radius prop is negative' , ( ) => {
502- const rectangle = ReactTestRenderer . create (
503- < Rectangle radiusBottomLeft = { - 25 } width = { 50 } height = { 50 } /> ,
504- ) ;
533+ it ( 'should generate a <Shape> with a radius property of 0 when bottom left radius prop is negative' , async ( ) => {
534+ let rectangle ;
535+ await act ( ( ) => {
536+ rectangle = ReactTestRenderer . create (
537+ < Rectangle radiusBottomLeft = { - 25 } width = { 50 } height = { 50 } /> ,
538+ ) ;
539+ } ) ;
505540 expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
506541 } ) ;
507542
508- it ( 'should generate a <Shape> where top radius is 0 if the sum of the top radius is greater than width' , ( ) => {
509- const rectangle = ReactTestRenderer . create (
510- < Rectangle
511- radiusTopRight = { 25 }
512- radiusTopLeft = { 26 }
513- width = { 50 }
514- height = { 40 }
515- /> ,
516- ) ;
543+ it ( 'should generate a <Shape> where top radius is 0 if the sum of the top radius is greater than width' , async ( ) => {
544+ let rectangle ;
545+ await act ( ( ) => {
546+ rectangle = ReactTestRenderer . create (
547+ < Rectangle
548+ radiusTopRight = { 25 }
549+ radiusTopLeft = { 26 }
550+ width = { 50 }
551+ height = { 40 }
552+ /> ,
553+ ) ;
554+ } ) ;
517555 expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
518556 } ) ;
519557
520- it ( 'should generate a <Shape> with props for drawing the Wedge' , ( ) => {
521- const wedge = ReactTestRenderer . create (
522- < Wedge outerRadius = { 50 } startAngle = { 0 } endAngle = { 360 } fill = "blue" /> ,
523- ) ;
558+ it ( 'should generate a <Shape> with props for drawing the Wedge' , async ( ) => {
559+ let wedge ;
560+ await act ( ( ) => {
561+ wedge = ReactTestRenderer . create (
562+ < Wedge outerRadius = { 50 } startAngle = { 0 } endAngle = { 360 } fill = "blue" /> ,
563+ ) ;
564+ } ) ;
524565 expect ( wedge . toJSON ( ) ) . toMatchSnapshot ( ) ;
525566 } ) ;
526567
527- it ( 'should return null if startAngle equals to endAngle on Wedge' , ( ) => {
528- const wedge = ReactTestRenderer . create (
529- < Wedge outerRadius = { 50 } startAngle = { 0 } endAngle = { 0 } fill = "blue" /> ,
530- ) ;
568+ it ( 'should return null if startAngle equals to endAngle on Wedge' , async ( ) => {
569+ let wedge ;
570+ await act ( ( ) => {
571+ wedge = ReactTestRenderer . create (
572+ < Wedge outerRadius = { 50 } startAngle = { 0 } endAngle = { 0 } fill = "blue" /> ,
573+ ) ;
574+ } ) ;
531575 expect ( wedge . toJSON ( ) ) . toBeNull ( ) ;
532576 } ) ;
533577} ) ;
0 commit comments