@@ -547,6 +547,7 @@ describe('config argument', function() {
547547 } ) ;
548548
549549 afterEach ( function ( ) {
550+ Plotly . purge ( gd ) ; // Needed to remove all event listeners
550551 destroyGraphDiv ( ) ;
551552 viewport . reset ( ) ;
552553 } ) ;
@@ -572,24 +573,6 @@ describe('config argument', function() {
572573 . catch ( failTest ) ;
573574 }
574575
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-
593576 it ( 'should resize when the viewport width/height changes' , function ( done ) {
594577 Plotly . plot ( gd , data , { } , { responsive : true } )
595578 . then ( testResponsive )
@@ -610,6 +593,24 @@ describe('config argument', function() {
610593 . then ( done ) ;
611594 } ) ;
612595
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+
613614 it ( 'should become responsive if configured as such via Plotly.react' , function ( done ) {
614615 Plotly . plot ( gd , data , { } , { responsive : false } )
615616 . then ( function ( ) { return Plotly . react ( gd , data , { } , { responsive : true } ) ; } )
0 commit comments