@@ -386,6 +386,9 @@ describe("$animator", function() {
386
386
window . setTimeout . expect ( 1 ) . process ( ) ;
387
387
window . setTimeout . expect ( 4000 ) . process ( ) ;
388
388
}
389
+ else {
390
+ expect ( window . setTimeout . queue . length ) . toBe ( 0 ) ;
391
+ }
389
392
expect ( element [ 0 ] . style . display ) . toBe ( '' ) ;
390
393
} ) ) ;
391
394
@@ -408,6 +411,9 @@ describe("$animator", function() {
408
411
window . setTimeout . expect ( 1 ) . process ( ) ;
409
412
window . setTimeout . expect ( 6000 ) . process ( ) ;
410
413
}
414
+ else {
415
+ expect ( window . setTimeout . queue . length ) . toBe ( 0 ) ;
416
+ }
411
417
expect ( element [ 0 ] . style . display ) . toBe ( '' ) ;
412
418
} ) ) ;
413
419
@@ -430,6 +436,9 @@ describe("$animator", function() {
430
436
window . setTimeout . expect ( 1 ) . process ( ) ;
431
437
window . setTimeout . expect ( 2000 ) . process ( ) ;
432
438
}
439
+ else {
440
+ expect ( window . setTimeout . queue . length ) . toBe ( 0 ) ;
441
+ }
433
442
expect ( element [ 0 ] . style . display ) . toBe ( '' ) ;
434
443
} ) ) ;
435
444
@@ -454,6 +463,9 @@ describe("$animator", function() {
454
463
window . setTimeout . expect ( 1 ) . process ( ) ;
455
464
window . setTimeout . expect ( 20000 ) . process ( ) ;
456
465
}
466
+ else {
467
+ expect ( window . setTimeout . queue . length ) . toBe ( 0 ) ;
468
+ }
457
469
expect ( element [ 0 ] . style . display ) . toBe ( '' ) ;
458
470
} ) ) ;
459
471
@@ -475,8 +487,6 @@ describe("$animator", function() {
475
487
476
488
it ( "should finish the previous animation when a new animation is started" ,
477
489
inject ( function ( $animator , $rootScope , $compile , $sniffer ) {
478
- if ( ! $sniffer . animations ) return ;
479
-
480
490
var style = 'animation: some_animation 2s linear 0s 1 alternate;' +
481
491
vendorPrefix + 'animation: some_animation 2s linear 0s 1 alternate;'
482
492
@@ -486,11 +496,19 @@ describe("$animator", function() {
486
496
} ) ;
487
497
488
498
animator . show ( element ) ;
489
- window . setTimeout . expect ( 1 ) . process ( ) ;
490
- expect ( element . hasClass ( 'show' ) ) . toBe ( true ) ;
491
- expect ( element . hasClass ( 'show-active' ) ) . toBe ( true ) ;
499
+ if ( $sniffer . animations ) {
500
+ window . setTimeout . expect ( 1 ) . process ( ) ;
501
+ expect ( element . hasClass ( 'show' ) ) . toBe ( true ) ;
502
+ expect ( element . hasClass ( 'show-active' ) ) . toBe ( true ) ;
503
+ }
504
+ else { //animation is skipped
505
+ expect ( window . setTimeout . queue . length ) . toBe ( 0 ) ;
506
+ }
492
507
493
508
animator . hide ( element ) ;
509
+ if ( ! $sniffer . animations ) {
510
+ expect ( window . setTimeout . queue . length ) . toBe ( 0 ) ;
511
+ }
494
512
expect ( element . hasClass ( 'show' ) ) . toBe ( false ) ;
495
513
expect ( element . hasClass ( 'show-active' ) ) . toBe ( false ) ;
496
514
} ) ) ;
@@ -520,6 +538,9 @@ describe("$animator", function() {
520
538
window . setTimeout . expect ( 1 ) . process ( ) ;
521
539
window . setTimeout . expect ( 1000 ) . process ( ) ;
522
540
}
541
+ else {
542
+ expect ( window . setTimeout . queue . length ) . toBe ( 0 ) ;
543
+ }
523
544
expect ( element [ 0 ] . style . display ) . toBe ( '' ) ;
524
545
} ) ) ;
525
546
@@ -536,6 +557,9 @@ describe("$animator", function() {
536
557
window . setTimeout . expect ( 1 ) . process ( ) ;
537
558
window . setTimeout . expect ( 2000 ) . process ( ) ;
538
559
}
560
+ else {
561
+ expect ( window . setTimeout . queue . length ) . toBe ( 0 ) ;
562
+ }
539
563
expect ( element [ 0 ] . style . display ) . toBe ( '' ) ;
540
564
} ) ) ;
541
565
@@ -565,29 +589,37 @@ describe("$animator", function() {
565
589
if ( $sniffer . transitions ) {
566
590
window . setTimeout . expect ( 1 ) . process ( ) ;
567
591
window . setTimeout . expect ( 3000 ) . process ( ) ;
568
- return ;
592
+ }
593
+ else {
594
+ expect ( window . setTimeout . queue . length ) . toBe ( 0 ) ;
569
595
}
570
596
expect ( element [ 0 ] . style . display ) . toBe ( '' ) ;
571
597
} ) ) ;
572
598
573
599
it ( "should finish the previous transition when a new animation is started" ,
574
600
inject ( function ( $animator , $rootScope , $compile , $sniffer ) {
575
- if ( ! $sniffer . animations ) return ;
576
-
577
601
var style = 'transition: 1s linear all;' +
578
- vendorPrefix + 'animation : 1s linear all;'
602
+ vendorPrefix + 'transition : 1s linear all;'
579
603
580
604
element = $compile ( html ( '<div style="' + style + '">1</div>' ) ) ( $rootScope ) ;
581
605
var animator = $animator ( $rootScope , {
582
606
ngAnimate : '{show: \'show\', hide: \'hide\'}'
583
607
} ) ;
584
608
585
609
animator . show ( element ) ;
586
- window . setTimeout . expect ( 1 ) . process ( ) ;
587
- expect ( element . hasClass ( 'show' ) ) . toBe ( true ) ;
588
- expect ( element . hasClass ( 'show-active' ) ) . toBe ( true ) ;
610
+ if ( $sniffer . transitions ) {
611
+ window . setTimeout . expect ( 1 ) . process ( ) ;
612
+ expect ( element . hasClass ( 'show' ) ) . toBe ( true ) ;
613
+ expect ( element . hasClass ( 'show-active' ) ) . toBe ( true ) ;
614
+ }
615
+ else { //animation is skipped
616
+ expect ( window . setTimeout . queue . length ) . toBe ( 0 ) ;
617
+ }
589
618
590
619
animator . hide ( element ) ;
620
+ if ( ! $sniffer . transitions ) {
621
+ expect ( window . setTimeout . queue . length ) . toBe ( 0 ) ;
622
+ }
591
623
expect ( element . hasClass ( 'show' ) ) . toBe ( false ) ;
592
624
expect ( element . hasClass ( 'show-active' ) ) . toBe ( false ) ;
593
625
} ) ) ;
0 commit comments