@@ -572,6 +572,24 @@ describe('config argument', function() {
572
572
. catch ( failTest ) ;
573
573
}
574
574
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
+
575
593
it ( 'should resize when the viewport width/height changes' , function ( done ) {
576
594
Plotly . plot ( gd , data , { } , { responsive : true } )
577
595
. then ( testResponsive )
@@ -592,23 +610,6 @@ describe('config argument', function() {
592
610
. then ( done ) ;
593
611
} ) ;
594
612
595
- it ( 'should only have one resize handler when plotted more than once' , function ( done ) {
596
- var cntWindowResize = 0 ;
597
- window . addEventListener ( 'resize' , function ( ) { cntWindowResize ++ ; } ) ;
598
- spyOn ( Plotly . Plots , 'resize' ) . and . callThrough ( ) ;
599
-
600
- Plotly . plot ( gd , data , { } , { responsive : true } )
601
- . then ( function ( ) { return Plotly . restyle ( gd , 'y[0]' , data [ 0 ] . y [ 0 ] + 2 ) ; } )
602
- . then ( function ( ) { viewport . set ( newWidth , newHeight ) ; } )
603
- . then ( delay ( 200 ) )
604
- . then ( function ( ) {
605
- expect ( cntWindowResize ) . toBe ( 1 ) ;
606
- expect ( Plotly . Plots . resize . calls . count ( ) ) . toBe ( 4 ) ;
607
- } )
608
- . catch ( failTest )
609
- . then ( done ) ;
610
- } ) ;
611
-
612
613
it ( 'should become responsive if configured as such via Plotly.react' , function ( done ) {
613
614
Plotly . plot ( gd , data , { } , { responsive : false } )
614
615
. then ( function ( ) { return Plotly . react ( gd , data , { } , { responsive : true } ) ; } )
0 commit comments