@@ -263,5 +263,57 @@ describe('Test frame api', function() {
263
263
return Plotly . Queue . redo ( gd ) ;
264
264
} ) . then ( validate ) . catch ( fail ) . then ( done ) ;
265
265
} ) ;
266
+
267
+ it ( 'deletes all frames if frameList is falsey' , function ( done ) {
268
+ var i ;
269
+ var n = 10 ;
270
+ var frames = [ ] ;
271
+ for ( i = 0 ; i < n ; i ++ ) {
272
+ frames . push ( { name : 'frame' + i } ) ;
273
+ }
274
+
275
+ function validateCount ( n ) {
276
+ return function ( ) {
277
+ expect ( f . length ) . toEqual ( n ) ;
278
+ } ;
279
+ }
280
+
281
+ Plotly . addFrames ( gd , frames ) . then ( function ( ) {
282
+ // Delete with no args:
283
+ return Plotly . deleteFrames ( gd ) ;
284
+ } ) . then ( validateCount ( 0 ) ) . then ( function ( ) {
285
+ // Restore:
286
+ return Plotly . Queue . undo ( gd ) ;
287
+ } ) . then ( validateCount ( n ) ) . then ( function ( ) {
288
+ // Delete with null arg:
289
+ return Plotly . deleteFrames ( gd , null ) ;
290
+ } ) . then ( validateCount ( 0 ) ) . then ( function ( ) {
291
+ // Restore:
292
+ return Plotly . Queue . undo ( gd ) ;
293
+ } ) . then ( validateCount ( n ) ) . then ( function ( ) {
294
+ // Delete with undefined:
295
+ return Plotly . deleteFrames ( gd , undefined ) ;
296
+ } ) . then ( validateCount ( 0 ) ) . catch ( fail ) . then ( done ) ;
297
+ } ) ;
298
+
299
+ it ( 'deleteFrames is a no-op with empty array' , function ( done ) {
300
+ var i ;
301
+ var n = 10 ;
302
+ var frames = [ ] ;
303
+ for ( i = 0 ; i < n ; i ++ ) {
304
+ frames . push ( { name : 'frame' + i } ) ;
305
+ }
306
+
307
+ function validateCount ( n ) {
308
+ return function ( ) {
309
+ expect ( f . length ) . toEqual ( n ) ;
310
+ } ;
311
+ }
312
+
313
+ Plotly . addFrames ( gd , frames ) . then ( function ( ) {
314
+ // Delete with no args:
315
+ return Plotly . deleteFrames ( gd , [ ] ) ;
316
+ } ) . then ( validateCount ( n ) ) . catch ( fail ) . then ( done ) ;
317
+ } ) ;
266
318
} ) ;
267
319
} ) ;
0 commit comments