@@ -4,7 +4,7 @@ var Plots = Plotly.Plots;
4
4
5
5
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
6
6
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
7
- var fail = require ( '../assets/fail_test' ) ;
7
+ var failTest = require ( '../assets/fail_test' ) ;
8
8
var delay = require ( '../assets/delay' ) ;
9
9
10
10
var mock = require ( '@mocks/animation' ) ;
@@ -174,19 +174,19 @@ describe('Test animate API', function() {
174
174
175
175
// traces are [0, 1]:
176
176
expect ( args [ 3 ] ) . toEqual ( [ 0 , 1 ] ) ;
177
- } ) . catch ( fail ) . then ( done ) ;
177
+ } ) . catch ( failTest ) . then ( done ) ;
178
178
} ) ;
179
179
180
180
it ( 'rejects if a frame is not found' , function ( done ) {
181
- Plotly . animate ( gd , [ 'foobar' ] , animOpts ) . then ( fail ) . then ( done , done ) ;
181
+ Plotly . animate ( gd , [ 'foobar' ] , animOpts ) . then ( failTest ) . then ( done , done ) ;
182
182
} ) ;
183
183
184
184
it ( 'treats objects as frames' , function ( done ) {
185
185
var frame = { data : [ { x : [ 1 , 2 , 3 ] } ] } ;
186
186
Plotly . animate ( gd , frame , animOpts ) . then ( function ( ) {
187
187
expect ( Plots . transition . calls . count ( ) ) . toEqual ( 1 ) ;
188
188
verifyQueueEmpty ( gd ) ;
189
- } ) . catch ( fail ) . then ( done ) ;
189
+ } ) . catch ( failTest ) . then ( done ) ;
190
190
} ) ;
191
191
192
192
it ( 'treats a list of objects as frames' , function ( done ) {
@@ -203,64 +203,64 @@ describe('Test animate API', function() {
203
203
204
204
expect ( Plots . transition . calls . count ( ) ) . toEqual ( 2 ) ;
205
205
verifyQueueEmpty ( gd ) ;
206
- } ) . catch ( fail ) . then ( done ) ;
206
+ } ) . catch ( failTest ) . then ( done ) ;
207
207
} ) ;
208
208
209
209
it ( 'animates all frames if list is null' , function ( done ) {
210
210
Plotly . animate ( gd , null , animOpts ) . then ( function ( ) {
211
211
verifyFrameTransitionOrder ( gd , [ 'base' , 'frame0' , 'frame1' , 'frame2' , 'frame3' ] ) ;
212
212
verifyQueueEmpty ( gd ) ;
213
- } ) . catch ( fail ) . then ( done ) ;
213
+ } ) . catch ( failTest ) . then ( done ) ;
214
214
} ) ;
215
215
216
216
it ( 'animates all frames if list is undefined' , function ( done ) {
217
217
Plotly . animate ( gd , undefined , animOpts ) . then ( function ( ) {
218
218
verifyFrameTransitionOrder ( gd , [ 'base' , 'frame0' , 'frame1' , 'frame2' , 'frame3' ] ) ;
219
219
verifyQueueEmpty ( gd ) ;
220
- } ) . catch ( fail ) . then ( done ) ;
220
+ } ) . catch ( failTest ) . then ( done ) ;
221
221
} ) ;
222
222
223
223
it ( 'animates to a single frame' , function ( done ) {
224
224
Plotly . animate ( gd , [ 'frame0' ] , animOpts ) . then ( function ( ) {
225
225
expect ( Plots . transition . calls . count ( ) ) . toEqual ( 1 ) ;
226
226
verifyQueueEmpty ( gd ) ;
227
- } ) . catch ( fail ) . then ( done ) ;
227
+ } ) . catch ( failTest ) . then ( done ) ;
228
228
} ) ;
229
229
230
230
it ( 'animates to an empty list' , function ( done ) {
231
231
Plotly . animate ( gd , [ ] , animOpts ) . then ( function ( ) {
232
232
expect ( Plots . transition . calls . count ( ) ) . toEqual ( 0 ) ;
233
233
verifyQueueEmpty ( gd ) ;
234
- } ) . catch ( fail ) . then ( done ) ;
234
+ } ) . catch ( failTest ) . then ( done ) ;
235
235
} ) ;
236
236
237
237
it ( 'animates to a list of frames' , function ( done ) {
238
238
Plotly . animate ( gd , [ 'frame0' , 'frame1' ] , animOpts ) . then ( function ( ) {
239
239
expect ( Plots . transition . calls . count ( ) ) . toEqual ( 2 ) ;
240
240
verifyQueueEmpty ( gd ) ;
241
- } ) . catch ( fail ) . then ( done ) ;
241
+ } ) . catch ( failTest ) . then ( done ) ;
242
242
} ) ;
243
243
244
244
it ( 'animates frames by group' , function ( done ) {
245
245
Plotly . animate ( gd , 'even-frames' , animOpts ) . then ( function ( ) {
246
246
expect ( Plots . transition . calls . count ( ) ) . toEqual ( 2 ) ;
247
247
verifyQueueEmpty ( gd ) ;
248
- } ) . catch ( fail ) . then ( done ) ;
248
+ } ) . catch ( failTest ) . then ( done ) ;
249
249
} ) ;
250
250
251
251
it ( 'animates frames in the correct order' , function ( done ) {
252
252
Plotly . animate ( gd , [ 'frame0' , 'frame2' , 'frame1' , 'frame3' ] , animOpts ) . then ( function ( ) {
253
253
verifyFrameTransitionOrder ( gd , [ 'frame0' , 'frame2' , 'frame1' , 'frame3' ] ) ;
254
254
verifyQueueEmpty ( gd ) ;
255
- } ) . catch ( fail ) . then ( done ) ;
255
+ } ) . catch ( failTest ) . then ( done ) ;
256
256
} ) ;
257
257
258
258
it ( 'accepts a single animationOpts' , function ( done ) {
259
259
Plotly . animate ( gd , [ 'frame0' , 'frame1' ] , { transition : { duration : 1.12345 } } ) . then ( function ( ) {
260
260
var calls = Plots . transition . calls ;
261
261
expect ( calls . argsFor ( 0 ) [ 5 ] . duration ) . toEqual ( 1.12345 ) ;
262
262
expect ( calls . argsFor ( 1 ) [ 5 ] . duration ) . toEqual ( 1.12345 ) ;
263
- } ) . catch ( fail ) . then ( done ) ;
263
+ } ) . catch ( failTest ) . then ( done ) ;
264
264
} ) ;
265
265
266
266
it ( 'accepts an array of animationOpts' , function ( done ) {
@@ -273,7 +273,7 @@ describe('Test animate API', function() {
273
273
expect ( calls . argsFor ( 1 ) [ 4 ] . duration ) . toEqual ( 5.4321 ) ;
274
274
expect ( calls . argsFor ( 0 ) [ 5 ] . duration ) . toEqual ( 1.123 ) ;
275
275
expect ( calls . argsFor ( 1 ) [ 5 ] . duration ) . toEqual ( 1.456 ) ;
276
- } ) . catch ( fail ) . then ( done ) ;
276
+ } ) . catch ( failTest ) . then ( done ) ;
277
277
} ) ;
278
278
279
279
it ( 'falls back to animationOpts[0] if not enough supplied in array' , function ( done ) {
@@ -286,7 +286,7 @@ describe('Test animate API', function() {
286
286
expect ( calls . argsFor ( 1 ) [ 4 ] . duration ) . toEqual ( 2.345 ) ;
287
287
expect ( calls . argsFor ( 0 ) [ 5 ] . duration ) . toEqual ( 1.123 ) ;
288
288
expect ( calls . argsFor ( 1 ) [ 5 ] . duration ) . toEqual ( 1.123 ) ;
289
- } ) . catch ( fail ) . then ( done ) ;
289
+ } ) . catch ( failTest ) . then ( done ) ;
290
290
} ) ;
291
291
292
292
it ( 'chains animations as promises' , function ( done ) {
@@ -295,7 +295,7 @@ describe('Test animate API', function() {
295
295
} ) . then ( function ( ) {
296
296
verifyFrameTransitionOrder ( gd , [ 'frame0' , 'frame1' , 'frame2' , 'frame3' ] ) ;
297
297
verifyQueueEmpty ( gd ) ;
298
- } ) . catch ( fail ) . then ( done ) ;
298
+ } ) . catch ( failTest ) . then ( done ) ;
299
299
} ) ;
300
300
301
301
it ( 'emits plotly_animated before the promise is resolved' , function ( done ) {
@@ -306,7 +306,7 @@ describe('Test animate API', function() {
306
306
307
307
Plotly . animate ( gd , [ 'frame0' ] , animOpts ) . then ( function ( ) {
308
308
expect ( animated ) . toBe ( true ) ;
309
- } ) . catch ( fail ) . then ( done ) ;
309
+ } ) . catch ( failTest ) . then ( done ) ;
310
310
} ) ;
311
311
312
312
it ( 'emits plotly_animated as each animation in a sequence completes' , function ( done ) {
@@ -332,7 +332,7 @@ describe('Test animate API', function() {
332
332
} ) . then ( function ( ) {
333
333
expect ( test1 ) . toBe ( 1 ) ;
334
334
expect ( test2 ) . toBe ( 1 ) ;
335
- } ) . catch ( fail ) . then ( done ) ;
335
+ } ) . catch ( failTest ) . then ( done ) ;
336
336
} ) ;
337
337
338
338
it ( 'resolves at the end of each animation sequence' , function ( done ) {
@@ -341,7 +341,7 @@ describe('Test animate API', function() {
341
341
} ) . then ( function ( ) {
342
342
verifyFrameTransitionOrder ( gd , [ 'frame0' , 'frame2' , 'frame0' , 'frame2' , 'frame1' , 'frame3' ] ) ;
343
343
verifyQueueEmpty ( gd ) ;
344
- } ) . catch ( fail ) . then ( done ) ;
344
+ } ) . catch ( failTest ) . then ( done ) ;
345
345
} ) ;
346
346
} ) ;
347
347
}
@@ -362,15 +362,15 @@ describe('Test animate API', function() {
362
362
Plotly . animate ( gd , [ 'frame0' , 'frame2' , 'frame1' , 'frame3' ] , animOpts ) . then ( function ( ) {
363
363
verifyFrameTransitionOrder ( gd , [ 'frame3' , 'frame1' , 'frame2' , 'frame0' ] ) ;
364
364
verifyQueueEmpty ( gd ) ;
365
- } ) . catch ( fail ) . then ( done ) ;
365
+ } ) . catch ( failTest ) . then ( done ) ;
366
366
} ) ;
367
367
368
368
it ( 'animates a group in reverse' , function ( done ) {
369
369
animOpts . direction = 'reverse' ;
370
370
Plotly . animate ( gd , 'even-frames' , animOpts ) . then ( function ( ) {
371
371
verifyFrameTransitionOrder ( gd , [ 'frame2' , 'frame0' ] ) ;
372
372
verifyQueueEmpty ( gd ) ;
373
- } ) . catch ( fail ) . then ( done ) ;
373
+ } ) . catch ( failTest ) . then ( done ) ;
374
374
} ) ;
375
375
} ) ;
376
376
@@ -394,7 +394,7 @@ describe('Test animate API', function() {
394
394
} ) . then ( function ( ) {
395
395
verifyFrameTransitionOrder ( gd , [ 'frame1' , 'frame2' , 'frame3' ] ) ;
396
396
verifyQueueEmpty ( gd ) ;
397
- } ) . catch ( fail ) . then ( done ) ;
397
+ } ) . catch ( failTest ) . then ( done ) ;
398
398
} ) ;
399
399
400
400
it ( 'plays from the start when current frame = last frame' , function ( done ) {
@@ -410,7 +410,7 @@ describe('Test animate API', function() {
410
410
] ) ;
411
411
412
412
verifyQueueEmpty ( gd ) ;
413
- } ) . catch ( fail ) . then ( done ) ;
413
+ } ) . catch ( failTest ) . then ( done ) ;
414
414
} ) ;
415
415
416
416
it ( 'animates in reverse starting at the current frame' , function ( done ) {
@@ -423,7 +423,7 @@ describe('Test animate API', function() {
423
423
} ) . then ( function ( ) {
424
424
verifyFrameTransitionOrder ( gd , [ 'frame1' , 'frame0' , 'base' ] ) ;
425
425
verifyQueueEmpty ( gd ) ;
426
- } ) . catch ( fail ) . then ( done ) ;
426
+ } ) . catch ( failTest ) . then ( done ) ;
427
427
} ) ;
428
428
429
429
it ( 'plays in reverse from the end when current frame = first frame' , function ( done ) {
@@ -440,7 +440,7 @@ describe('Test animate API', function() {
440
440
] ) ;
441
441
442
442
verifyQueueEmpty ( gd ) ;
443
- } ) . catch ( fail ) . then ( done ) ;
443
+ } ) . catch ( failTest ) . then ( done ) ;
444
444
} ) ;
445
445
} ) ;
446
446
@@ -467,7 +467,7 @@ describe('Test animate API', function() {
467
467
Plotly . animate ( gd , [ 'frame2' ] , Lib . extendFlat ( animOpts , { mode : 'immediate' } ) ) . then ( function ( ) {
468
468
expect ( interrupted ) . toBe ( true ) ;
469
469
verifyQueueEmpty ( gd ) ;
470
- } ) . catch ( fail ) . then ( done ) ;
470
+ } ) . catch ( failTest ) . then ( done ) ;
471
471
} ) ;
472
472
473
473
it ( 'queues successive animations' , function ( done ) {
@@ -486,52 +486,52 @@ describe('Test animate API', function() {
486
486
Plotly . animate ( gd , 'odd-frames' , { transition : { duration : 16 } } ) . then ( delay ( 10 ) ) . then ( function ( ) {
487
487
expect ( ends ) . toEqual ( 1 ) ;
488
488
verifyQueueEmpty ( gd ) ;
489
- } ) . catch ( fail ) . then ( done ) ;
489
+ } ) . catch ( failTest ) . then ( done ) ;
490
490
} ) ;
491
491
492
492
it ( 'an empty list with immediate dumps previous frames' , function ( done ) {
493
493
Plotly . animate ( gd , [ 'frame0' , 'frame1' ] , { frame : { duration : 50 } } ) ;
494
494
Plotly . animate ( gd , [ ] , { mode : 'immediate' } ) . then ( function ( ) {
495
495
expect ( Plots . transition . calls . count ( ) ) . toEqual ( 1 ) ;
496
496
verifyQueueEmpty ( gd ) ;
497
- } ) . catch ( fail ) . then ( done ) ;
497
+ } ) . catch ( failTest ) . then ( done ) ;
498
498
} ) ;
499
499
500
500
it ( 'animates groups in the correct order' , function ( done ) {
501
501
Plotly . animate ( gd , 'even-frames' , animOpts ) ;
502
502
Plotly . animate ( gd , 'odd-frames' , animOpts ) . then ( function ( ) {
503
503
verifyFrameTransitionOrder ( gd , [ 'frame0' , 'frame2' , 'frame1' , 'frame3' ] ) ;
504
504
verifyQueueEmpty ( gd ) ;
505
- } ) . catch ( fail ) . then ( done ) ;
505
+ } ) . catch ( failTest ) . then ( done ) ;
506
506
} ) ;
507
507
508
508
it ( 'drops queued frames when immediate = true' , function ( done ) {
509
509
Plotly . animate ( gd , 'even-frames' , animOpts ) ;
510
510
Plotly . animate ( gd , 'odd-frames' , Lib . extendFlat ( animOpts , { mode : 'immediate' } ) ) . then ( function ( ) {
511
511
verifyFrameTransitionOrder ( gd , [ 'frame0' , 'frame1' , 'frame3' ] ) ;
512
512
verifyQueueEmpty ( gd ) ;
513
- } ) . catch ( fail ) . then ( done ) ;
513
+ } ) . catch ( failTest ) . then ( done ) ;
514
514
} ) ;
515
515
516
516
it ( 'animates frames and groups in sequence' , function ( done ) {
517
517
Plotly . animate ( gd , 'even-frames' , animOpts ) ;
518
518
Plotly . animate ( gd , [ 'frame0' , 'frame2' , 'frame1' , 'frame3' ] , animOpts ) . then ( function ( ) {
519
519
verifyFrameTransitionOrder ( gd , [ 'frame0' , 'frame2' , 'frame0' , 'frame2' , 'frame1' , 'frame3' ] ) ;
520
520
verifyQueueEmpty ( gd ) ;
521
- } ) . catch ( fail ) . then ( done ) ;
521
+ } ) . catch ( failTest ) . then ( done ) ;
522
522
} ) ;
523
523
524
524
it ( 'rejects when an animation is interrupted' , function ( done ) {
525
525
var interrupted = false ;
526
- Plotly . animate ( gd , [ 'frame0' , 'frame1' ] , animOpts ) . then ( fail , function ( ) {
526
+ Plotly . animate ( gd , [ 'frame0' , 'frame1' ] , animOpts ) . then ( failTest , function ( ) {
527
527
interrupted = true ;
528
528
} ) ;
529
529
530
530
Plotly . animate ( gd , [ 'frame2' ] , Lib . extendFlat ( animOpts , { mode : 'immediate' } ) ) . then ( function ( ) {
531
531
expect ( interrupted ) . toBe ( true ) ;
532
532
verifyFrameTransitionOrder ( gd , [ 'frame0' , 'frame2' ] ) ;
533
533
verifyQueueEmpty ( gd ) ;
534
- } ) . catch ( fail ) . then ( done ) ;
534
+ } ) . catch ( failTest ) . then ( done ) ;
535
535
} ) ;
536
536
} ) ;
537
537
@@ -550,7 +550,7 @@ describe('Test animate API', function() {
550
550
frame : { duration : 1 }
551
551
} ) . then ( function ( ) {
552
552
expect ( frames ) . toEqual ( [ 'frame0' , 'frame1' , null , null ] ) ;
553
- } ) . catch ( fail ) . then ( done ) ;
553
+ } ) . catch ( failTest ) . then ( done ) ;
554
554
555
555
} ) ;
556
556
} ) ;
@@ -567,7 +567,7 @@ describe('Test animate API', function() {
567
567
// Transition timing:
568
568
expect ( Plots . transition . calls . argsFor ( 0 ) [ 5 ] . duration ) . toEqual ( 50 ) ;
569
569
570
- } ) . catch ( fail ) . then ( done ) ;
570
+ } ) . catch ( failTest ) . then ( done ) ;
571
571
} ) ;
572
572
573
573
it ( 'limits the transition duration to <= frame duration (matching per-config)' , function ( done ) {
@@ -583,7 +583,7 @@ describe('Test animate API', function() {
583
583
expect ( Plots . transition . calls . argsFor ( 0 ) [ 5 ] . duration ) . toEqual ( 50 ) ;
584
584
expect ( Plots . transition . calls . argsFor ( 1 ) [ 5 ] . duration ) . toEqual ( 40 ) ;
585
585
586
- } ) . catch ( fail ) . then ( done ) ;
586
+ } ) . catch ( failTest ) . then ( done ) ;
587
587
} ) ;
588
588
} ) ;
589
589
} ) ;
@@ -615,7 +615,7 @@ describe('Animate API details', function() {
615
615
{ frame : { redraw : true , duration : dur } , transition : { duration : dur } }
616
616
) . then ( function ( ) {
617
617
expect ( redraws ) . toBe ( 1 ) ;
618
- } ) . catch ( fail ) . then ( done ) ;
618
+ } ) . catch ( failTest ) . then ( done ) ;
619
619
} ) ;
620
620
621
621
it ( 'forces a relayout after layout animations' , function ( done ) {
@@ -633,7 +633,7 @@ describe('Animate API details', function() {
633
633
expect ( relayouts ) . toBe ( 1 ) ;
634
634
expect ( restyles ) . toBe ( 0 ) ;
635
635
expect ( redraws ) . toBe ( 0 ) ;
636
- } ) . catch ( fail ) . then ( done ) ;
636
+ } ) . catch ( failTest ) . then ( done ) ;
637
637
} ) ;
638
638
639
639
it ( 'triggers plotly_animated after a single layout animation' , function ( done ) {
@@ -679,7 +679,7 @@ describe('Animate API details', function() {
679
679
} ) . then ( function ( ) {
680
680
// Confirm the result:
681
681
expect ( gd . data [ 0 ] . x ) . toEqual ( [ 8 , 7 , 6 ] ) ;
682
- } ) . catch ( fail ) . then ( done ) ;
682
+ } ) . catch ( failTest ) . then ( done ) ;
683
683
} ) ;
684
684
685
685
it ( 'ignores null and undefined frames' , function ( done ) {
@@ -694,7 +694,7 @@ describe('Animate API details', function() {
694
694
695
695
// Check unused frames did not affect the current frame:
696
696
expect ( gd . _fullLayout . _currentFrame ) . toEqual ( 'frame0' ) ;
697
- } ) . catch ( fail ) . then ( done ) ;
697
+ } ) . catch ( failTest ) . then ( done ) ;
698
698
} ) ;
699
699
700
700
it ( 'null frames should not break everything' , function ( done ) {
@@ -703,7 +703,7 @@ describe('Animate API details', function() {
703
703
Plotly . animate ( gd , null , {
704
704
frame : { duration : 0 } ,
705
705
transition : { duration : 0 }
706
- } ) . catch ( fail ) . then ( done ) ;
706
+ } ) . catch ( failTest ) . then ( done ) ;
707
707
} ) ;
708
708
} ) ;
709
709
@@ -747,7 +747,7 @@ describe('Animating multiple axes', function() {
747
747
expect ( gd . _fullLayout . yaxis . range ) . toEqual ( [ 2 , 3 ] ) ;
748
748
expect ( gd . _fullLayout . yaxis2 . range ) . toEqual ( [ 1 , 2 ] ) ;
749
749
} )
750
- . catch ( fail )
750
+ . catch ( failTest )
751
751
. then ( done ) ;
752
752
} ) ;
753
753
} ) ;
@@ -778,7 +778,7 @@ describe('non-animatable fallback', function() {
778
778
} ] , { frame : { duration : 0 } } ) ;
779
779
} ) . then ( function ( ) {
780
780
expect ( gd . data [ 0 ] . y ) . toEqual ( [ 6 , 4 , 5 ] ) ;
781
- } ) . catch ( fail ) . then ( done ) ;
781
+ } ) . catch ( failTest ) . then ( done ) ;
782
782
783
783
} ) ;
784
784
} ) ;
@@ -812,7 +812,7 @@ describe('animating scatter traces', function() {
812
812
} ] , { transition : { duration : 0 } , frame : { duration : 0 , redraw : false } } ) ;
813
813
} ) . then ( function ( ) {
814
814
expect ( trace . node ( ) . style . opacity ) . toEqual ( '0.1' ) ;
815
- } ) . catch ( fail ) . then ( done ) ;
815
+ } ) . catch ( failTest ) . then ( done ) ;
816
816
} ) ;
817
817
818
818
it ( 'computes calcdata correctly when transforms are present' , function ( done ) {
@@ -834,6 +834,6 @@ describe('animating scatter traces', function() {
834
834
return Plotly . animate ( gd , [ 'frame2' ] , { frame : { duration : 200 , redraw : false } } ) ;
835
835
} ) . then ( function ( ) {
836
836
expect ( gd . calcdata [ 0 ] [ 0 ] . y ) . toEqual ( 3 ) ;
837
- } ) . catch ( fail ) . then ( done ) ;
837
+ } ) . catch ( failTest ) . then ( done ) ;
838
838
} ) ;
839
839
} ) ;
0 commit comments