@@ -24,13 +24,8 @@ import Wedge from 'react-art/Wedge';
24
24
25
25
// Isolate DOM renderer.
26
26
jest . resetModules ( ) ;
27
-
28
27
const 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 ;
34
29
35
30
// Isolate the noop renderer
36
31
jest . resetModules ( ) ;
@@ -73,6 +68,7 @@ describe('ReactART', () => {
73
68
let container ;
74
69
75
70
beforeEach ( ( ) => {
71
+ jest . resetModules ( ) ;
76
72
container = document . createElement ( 'div' ) ;
77
73
document . body . appendChild ( container ) ;
78
74
@@ -449,85 +445,136 @@ describe('ReactART', () => {
449
445
} ) ;
450
446
451
447
describe ( '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
- ) ;
448
+ let ReactTestRenderer ;
449
+ beforeEach ( ( ) => {
450
+ jest . resetModules ( ) ;
451
+ ReactTestRenderer = require ( 'react-test-renderer' ) ;
452
+ act = require ( 'internal-test-utils' ) . act ;
453
+ } ) ;
454
+
455
+ it ( 'should generate a <Shape> with props for drawing the Circle' , async ( ) => {
456
+ let circle ;
457
+ await act ( ( ) => {
458
+ circle = ReactTestRenderer . create (
459
+ < Circle radius = { 10 } stroke = "green" strokeWidth = { 3 } fill = "blue" /> ,
460
+ { unstable_isConcurrent : true } ,
461
+ ) ;
462
+ } ) ;
456
463
expect ( circle . toJSON ( ) ) . toMatchSnapshot ( ) ;
457
464
} ) ;
458
465
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
- ) ;
466
+ it ( 'should generate a <Shape> with props for drawing the Rectangle' , async ( ) => {
467
+ let rectangle ;
468
+ await act ( ( ) => {
469
+ rectangle = ReactTestRenderer . create (
470
+ < Rectangle width = { 50 } height = { 50 } stroke = "green" fill = "blue" /> ,
471
+ { unstable_isConcurrent : true } ,
472
+ ) ;
473
+ } ) ;
463
474
expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
464
475
} ) ;
465
476
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
- ) ;
477
+ it ( 'should generate a <Shape> with positive width when width prop is negative' , async ( ) => {
478
+ let rectangle ;
479
+ await act ( ( ) => {
480
+ rectangle = ReactTestRenderer . create (
481
+ < Rectangle width = { - 50 } height = { 50 } /> ,
482
+ { unstable_isConcurrent : true } ,
483
+ ) ;
484
+ } ) ;
470
485
expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
471
486
} ) ;
472
487
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
- ) ;
488
+ it ( 'should generate a <Shape> with positive height when height prop is negative' , async ( ) => {
489
+ let rectangle ;
490
+ await act ( ( ) => {
491
+ rectangle = ReactTestRenderer . create (
492
+ < Rectangle height = { - 50 } width = { 50 } /> ,
493
+ { unstable_isConcurrent : true } ,
494
+ ) ;
495
+ } ) ;
477
496
expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
478
497
} ) ;
479
498
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
- ) ;
499
+ it ( 'should generate a <Shape> with a radius property of 0 when top left radius prop is negative' , async ( ) => {
500
+ let rectangle ;
501
+ await act ( ( ) => {
502
+ rectangle = ReactTestRenderer . create (
503
+ < Rectangle radiusTopLeft = { - 25 } width = { 50 } height = { 50 } /> ,
504
+ { unstable_isConcurrent : true } ,
505
+ ) ;
506
+ } ) ;
484
507
expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
485
508
} ) ;
486
509
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
- ) ;
510
+ it ( 'should generate a <Shape> with a radius property of 0 when top right radius prop is negative' , async ( ) => {
511
+ let rectangle ;
512
+ await act ( ( ) => {
513
+ rectangle = ReactTestRenderer . create (
514
+ < Rectangle radiusTopRight = { - 25 } width = { 50 } height = { 50 } /> ,
515
+ { unstable_isConcurrent : true } ,
516
+ ) ;
517
+ } ) ;
491
518
expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
492
519
} ) ;
493
520
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
- ) ;
521
+ it ( 'should generate a <Shape> with a radius property of 0 when bottom right radius prop is negative' , async ( ) => {
522
+ let rectangle ;
523
+ await act ( ( ) => {
524
+ rectangle = ReactTestRenderer . create (
525
+ < Rectangle radiusBottomRight = { - 30 } width = { 50 } height = { 50 } /> ,
526
+ { unstable_isConcurrent : true } ,
527
+ ) ;
528
+ } ) ;
498
529
expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
499
530
} ) ;
500
531
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
- ) ;
532
+ it ( 'should generate a <Shape> with a radius property of 0 when bottom left radius prop is negative' , async ( ) => {
533
+ let rectangle ;
534
+ await act ( ( ) => {
535
+ rectangle = ReactTestRenderer . create (
536
+ < Rectangle radiusBottomLeft = { - 25 } width = { 50 } height = { 50 } /> ,
537
+ { unstable_isConcurrent : true } ,
538
+ ) ;
539
+ } ) ;
505
540
expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
506
541
} ) ;
507
542
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
+ { unstable_isConcurrent : true } ,
554
+ ) ;
555
+ } ) ;
517
556
expect ( rectangle . toJSON ( ) ) . toMatchSnapshot ( ) ;
518
557
} ) ;
519
558
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
- ) ;
559
+ it ( 'should generate a <Shape> with props for drawing the Wedge' , async ( ) => {
560
+ let wedge ;
561
+ await act ( ( ) => {
562
+ wedge = ReactTestRenderer . create (
563
+ < Wedge outerRadius = { 50 } startAngle = { 0 } endAngle = { 360 } fill = "blue" /> ,
564
+ { unstable_isConcurrent : true } ,
565
+ ) ;
566
+ } ) ;
524
567
expect ( wedge . toJSON ( ) ) . toMatchSnapshot ( ) ;
525
568
} ) ;
526
569
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
- ) ;
570
+ it ( 'should return null if startAngle equals to endAngle on Wedge' , async ( ) => {
571
+ let wedge ;
572
+ await act ( ( ) => {
573
+ wedge = ReactTestRenderer . create (
574
+ < Wedge outerRadius = { 50 } startAngle = { 0 } endAngle = { 0 } fill = "blue" /> ,
575
+ { unstable_isConcurrent : true } ,
576
+ ) ;
577
+ } ) ;
531
578
expect ( wedge . toJSON ( ) ) . toBeNull ( ) ;
532
579
} ) ;
533
580
} ) ;
0 commit comments