File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,9 @@ plots.resize = function(gd) {
8181 reject ( new Error ( 'Resize must be passed a displayed plot div element.' ) ) ;
8282 }
8383
84+ if ( gd . _rejectResize ) gd . _rejectResize ( ) ;
85+ gd . _rejectResize = reject ;
86+
8487 if ( gd . _redrawTimer ) clearTimeout ( gd . _redrawTimer ) ;
8588
8689 gd . _redrawTimer = setTimeout ( function ( ) {
Original file line number Diff line number Diff line change @@ -412,6 +412,27 @@ describe('Test Plots', function() {
412412 . then ( done ) ;
413413 } ) ;
414414 } ) ;
415+
416+ describe ( 'returns Promises' , function ( ) {
417+ afterEach ( destroyGraphDiv ) ;
418+
419+ it ( 'should reject or resolve them all' , function ( done ) {
420+ gd = createGraphDiv ( ) ;
421+ var p = [ ] ;
422+ Plotly . newPlot ( gd , [ { y : [ 5 , 2 , 5 ] } ] )
423+ . then ( function ( ) {
424+ // First call should get rejected
425+ p . push ( Plotly . Plots . resize ( gd ) . catch ( function ( ) {
426+ return Promise . resolve ( true ) ;
427+ } ) ) ;
428+ // because we call the function again within 100ms
429+ p . push ( Plotly . Plots . resize ( gd ) ) ;
430+ return Promise . all ( p ) ;
431+ } )
432+ . catch ( failTest )
433+ . then ( done ) ;
434+ } ) ;
435+ } ) ;
415436 } ) ;
416437
417438 describe ( 'Plots.purge' , function ( ) {
You can’t perform that action at this time.
0 commit comments