@@ -547,6 +547,7 @@ describe('config argument', function() {
547
547
} ) ;
548
548
549
549
afterEach ( function ( ) {
550
+ Plotly . purge ( gd ) ; // Needed to remove all event listeners
550
551
destroyGraphDiv ( ) ;
551
552
viewport . reset ( ) ;
552
553
} ) ;
@@ -572,24 +573,6 @@ describe('config argument', function() {
572
573
. catch ( failTest ) ;
573
574
}
574
575
575
- it ( 'should only have one resize handler when plotted more than once' , function ( done ) {
576
- var cntWindowResize = 0 ;
577
- window . addEventListener ( 'resize' , function ( ) { cntWindowResize ++ ; } ) ;
578
- spyOn ( Plotly . Plots , 'resize' ) . and . callThrough ( ) ;
579
-
580
- Plotly . plot ( gd , data , { } , { responsive : true } )
581
- . then ( function ( ) { return Plotly . restyle ( gd , 'y[0]' , data [ 0 ] . y [ 0 ] + 2 ) ; } )
582
- . then ( function ( ) { viewport . set ( newWidth , newHeight ) ; } )
583
- . then ( delay ( 200 ) )
584
- // .then(function() {viewport.set(newWidth, 2 * newHeight);}).then(delay(200))
585
- . then ( function ( ) {
586
- expect ( cntWindowResize ) . toBe ( 1 ) ;
587
- expect ( Plotly . Plots . resize . calls . count ( ) ) . toBe ( 1 ) ;
588
- } )
589
- . catch ( failTest )
590
- . then ( done ) ;
591
- } ) ;
592
-
593
576
it ( 'should resize when the viewport width/height changes' , function ( done ) {
594
577
Plotly . plot ( gd , data , { } , { responsive : true } )
595
578
. then ( testResponsive )
@@ -610,6 +593,24 @@ describe('config argument', function() {
610
593
. then ( done ) ;
611
594
} ) ;
612
595
596
+ it ( 'should only have one resize handler when plotted more than once' , function ( done ) {
597
+ var cntWindowResize = 0 ;
598
+ window . addEventListener ( 'resize' , function ( ) { cntWindowResize ++ ; } ) ;
599
+ spyOn ( Plotly . Plots , 'resize' ) . and . callThrough ( ) ;
600
+
601
+ Plotly . plot ( gd , data , { } , { responsive : true } )
602
+ . then ( function ( ) { return Plotly . restyle ( gd , 'y[0]' , data [ 0 ] . y [ 0 ] + 2 ) ; } )
603
+ . then ( function ( ) { viewport . set ( newWidth , newHeight ) ; } )
604
+ . then ( delay ( 200 ) )
605
+ // .then(function() {viewport.set(newWidth, 2 * newHeight);}).then(delay(200))
606
+ . then ( function ( ) {
607
+ expect ( cntWindowResize ) . toBe ( 1 ) ;
608
+ expect ( Plotly . Plots . resize . calls . count ( ) ) . toBe ( 1 ) ;
609
+ } )
610
+ . catch ( failTest )
611
+ . then ( done ) ;
612
+ } ) ;
613
+
613
614
it ( 'should become responsive if configured as such via Plotly.react' , function ( done ) {
614
615
Plotly . plot ( gd , data , { } , { responsive : false } )
615
616
. then ( function ( ) { return Plotly . react ( gd , data , { } , { responsive : true } ) ; } )
0 commit comments