@@ -2,7 +2,7 @@ var Plotly = require('@lib/index');
2
2
var Events = require ( '@src/lib/events' ) ;
3
3
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
4
4
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
5
-
5
+ var failTest = require ( '../assets/fail_test' ) ;
6
6
7
7
describe ( 'Plotly.___ methods' , function ( ) {
8
8
'use strict' ;
@@ -468,7 +468,9 @@ describe('Plotly.___ methods', function() {
468
468
expect ( gd ) . toBeDefined ( ) ;
469
469
expect ( typeof gd ) . toBe ( 'object' ) ;
470
470
expect ( gd . layout ) . toBeDefined ( ) ;
471
- } ) . then ( done ) ;
471
+ } )
472
+ . catch ( failTest )
473
+ . then ( done ) ;
472
474
} ) ;
473
475
474
476
it ( 'should return a rejected promise if gd is hidden' , function ( done ) {
@@ -478,7 +480,9 @@ describe('Plotly.___ methods', function() {
478
480
} , function ( err ) {
479
481
expect ( err ) . toBeDefined ( ) ;
480
482
expect ( err . message ) . toBe ( 'Resize must be passed a displayed plot div element.' ) ;
481
- } ) . then ( done ) ;
483
+ } )
484
+ . catch ( failTest )
485
+ . then ( done ) ;
482
486
} ) ;
483
487
484
488
it ( 'should return a rejected promise if gd is detached from the DOM' , function ( done ) {
@@ -488,7 +492,30 @@ describe('Plotly.___ methods', function() {
488
492
} , function ( err ) {
489
493
expect ( err ) . toBeDefined ( ) ;
490
494
expect ( err . message ) . toBe ( 'Resize must be passed a displayed plot div element.' ) ;
491
- } ) . then ( done ) ;
495
+ } )
496
+ . catch ( failTest )
497
+ . then ( done ) ;
498
+ } ) ;
499
+
500
+ it ( 'should return a resolved promise if plot has been purged and there is nothing to resize' , function ( done ) {
501
+ var resizePromise = Plotly . Plots . resize ( initialDiv ) ;
502
+
503
+ Plotly . purge ( initialDiv ) ;
504
+ destroyGraphDiv ( ) ;
505
+
506
+ resizePromise
507
+ . catch ( failTest )
508
+ . then ( done ) ;
509
+ } ) ;
510
+
511
+ it ( 'should return a resolved promise if plot has been hidden and gd is hidden' , function ( done ) {
512
+ var resizePromise = Plotly . Plots . resize ( initialDiv ) ;
513
+
514
+ initialDiv . style . display = 'none' ;
515
+
516
+ resizePromise
517
+ . catch ( failTest )
518
+ . then ( done ) ;
492
519
} ) ;
493
520
494
521
it ( 'errors before even generating a promise if gd is not defined' , function ( ) {
0 commit comments