File tree 2 files changed +24
-0
lines changed
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) {
81
81
reject ( new Error ( 'Resize must be passed a displayed plot div element.' ) ) ;
82
82
}
83
83
84
+ if ( gd . _rejectResize ) gd . _rejectResize ( ) ;
85
+ gd . _rejectResize = reject ;
86
+
84
87
if ( gd . _redrawTimer ) clearTimeout ( gd . _redrawTimer ) ;
85
88
86
89
gd . _redrawTimer = setTimeout ( function ( ) {
Original file line number Diff line number Diff line change @@ -412,6 +412,27 @@ describe('Test Plots', function() {
412
412
. then ( done ) ;
413
413
} ) ;
414
414
} ) ;
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
+ } ) ;
415
436
} ) ;
416
437
417
438
describe ( 'Plots.purge' , function ( ) {
You can’t perform that action at this time.
0 commit comments