@@ -491,7 +491,7 @@ describe("ngAnimate", function() {
491
491
$animate . triggerReflow ( ) ;
492
492
493
493
//this is to verify that the existing style is appended with a semicolon automatically
494
- expect ( child . attr ( 'style' ) ) . toMatch ( / w i d t h : 2 0 p x ; .+ ?/ i) ;
494
+ expect ( child . attr ( 'style' ) ) . toMatch ( / w i d t h : 2 0 p x ; .* ?/ i) ;
495
495
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
496
496
}
497
497
@@ -564,15 +564,15 @@ describe("ngAnimate", function() {
564
564
} ) ;
565
565
} ) ;
566
566
567
- it ( "should fire the cancel/end function with the correct flag in the parameters " ,
567
+ it ( "should not apply a cancellation when addClass is done multiple times " ,
568
568
inject ( function ( $animate , $rootScope , $sniffer , $timeout ) {
569
569
570
570
element . append ( child ) ;
571
571
572
572
$animate . addClass ( child , 'custom-delay' ) ;
573
573
$animate . addClass ( child , 'custom-long-delay' ) ;
574
574
575
- expect ( child . hasClass ( 'animation-cancelled' ) ) . toBe ( true ) ;
575
+ expect ( child . hasClass ( 'animation-cancelled' ) ) . toBe ( false ) ;
576
576
expect ( child . hasClass ( 'animation-ended' ) ) . toBe ( false ) ;
577
577
578
578
$timeout . flush ( ) ;
@@ -764,7 +764,6 @@ describe("ngAnimate", function() {
764
764
$animate . addClass ( element , 'ng-hide' ) ;
765
765
expect ( element . hasClass ( 'ng-hide-remove' ) ) . toBe ( false ) ; //added right away
766
766
767
-
768
767
if ( $sniffer . animations ) { //cleanup some pending animations
769
768
$animate . triggerReflow ( ) ;
770
769
expect ( element . hasClass ( 'ng-hide-add' ) ) . toBe ( true ) ;
@@ -1472,6 +1471,8 @@ describe("ngAnimate", function() {
1472
1471
1473
1472
expect ( flag ) . toBe ( true ) ;
1474
1473
expect ( element . parent ( ) . id ) . toBe ( parent2 . id ) ;
1474
+
1475
+ dealoc ( element ) ;
1475
1476
} ) ) ;
1476
1477
1477
1478
@@ -1620,11 +1621,12 @@ describe("ngAnimate", function() {
1620
1621
var element = parent . find ( 'span' ) ;
1621
1622
1622
1623
var flag = false ;
1623
- $animate . removeClass ( element , 'ng-hide' , function ( ) {
1624
+ $animate . addClass ( element , 'ng-hide' , function ( ) {
1624
1625
flag = true ;
1625
1626
} ) ;
1626
1627
1627
1628
if ( $sniffer . transitions ) {
1629
+ $animate . triggerReflow ( ) ;
1628
1630
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
1629
1631
}
1630
1632
$timeout . flush ( ) ;
@@ -2734,42 +2736,6 @@ describe("ngAnimate", function() {
2734
2736
} ) ;
2735
2737
2736
2738
2737
- it ( "should cancel an ongoing class-based animation only if the new class contains transition/animation CSS code" ,
2738
- inject ( function ( $compile , $rootScope , $animate , $sniffer , $timeout ) {
2739
-
2740
- if ( ! $sniffer . transitions ) return ;
2741
-
2742
- ss . addRule ( '.green-add' , '-webkit-transition:1s linear all;' +
2743
- 'transition:1s linear all;' ) ;
2744
-
2745
- ss . addRule ( '.blue-add' , 'background:blue;' ) ;
2746
-
2747
- ss . addRule ( '.red-add' , '-webkit-transition:1s linear all;' +
2748
- 'transition:1s linear all;' ) ;
2749
-
2750
- ss . addRule ( '.yellow-add' , '-webkit-animation: some_animation 4s linear 1s 2 alternate;' +
2751
- 'animation: some_animation 4s linear 1s 2 alternate;' ) ;
2752
-
2753
- var element = $compile ( '<div></div>' ) ( $rootScope ) ;
2754
- $rootElement . append ( element ) ;
2755
- jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
2756
-
2757
- $animate . addClass ( element , 'green' ) ;
2758
- expect ( element . hasClass ( 'green-add' ) ) . toBe ( true ) ;
2759
-
2760
- $animate . addClass ( element , 'blue' ) ;
2761
- expect ( element . hasClass ( 'blue' ) ) . toBe ( true ) ;
2762
- expect ( element . hasClass ( 'green-add' ) ) . toBe ( true ) ; //not cancelled
2763
-
2764
- $animate . addClass ( element , 'red' ) ;
2765
- expect ( element . hasClass ( 'green-add' ) ) . toBe ( false ) ;
2766
- expect ( element . hasClass ( 'red-add' ) ) . toBe ( true ) ;
2767
-
2768
- $animate . addClass ( element , 'yellow' ) ;
2769
- expect ( element . hasClass ( 'red-add' ) ) . toBe ( false ) ;
2770
- expect ( element . hasClass ( 'yellow-add' ) ) . toBe ( true ) ;
2771
- } ) ) ;
2772
-
2773
2739
2774
2740
it ( "should cancel and perform the dom operation only after the reflow has run" ,
2775
2741
inject ( function ( $compile , $rootScope , $animate , $sniffer , $timeout ) {
@@ -2837,7 +2803,7 @@ describe("ngAnimate", function() {
2837
2803
$animate . removeClass ( element , 'on' ) ;
2838
2804
$animate . addClass ( element , 'on' ) ;
2839
2805
2840
- expect ( currentAnimation ) . toBe ( null ) ;
2806
+ expect ( currentAnimation ) . toBe ( 'addClass' ) ;
2841
2807
} ) ;
2842
2808
} ) ;
2843
2809
@@ -3259,7 +3225,7 @@ describe("ngAnimate", function() {
3259
3225
expect ( ready ) . toBe ( true ) ;
3260
3226
} ) ) ;
3261
3227
3262
- it ( 'should avoid skip animations if the same CSS class is added / removed synchronously before the reflow kicks in ' ,
3228
+ it ( 'should immediately close the former animation if the same CSS class is added/ removed' ,
3263
3229
inject ( function ( $sniffer , $compile , $rootScope , $rootElement , $animate , $timeout ) {
3264
3230
3265
3231
if ( ! $sniffer . transitions ) return ;
@@ -3281,28 +3247,15 @@ describe("ngAnimate", function() {
3281
3247
signature += 'B' ;
3282
3248
} ) ;
3283
3249
3284
- $timeout . flush ( 1 ) ;
3285
- expect ( signature ) . toBe ( 'AB' ) ;
3286
-
3287
- signature = '' ;
3288
- $animate . removeClass ( element , 'on' , function ( ) {
3289
- signature += 'A' ;
3290
- } ) ;
3291
- $animate . addClass ( element , 'on' , function ( ) {
3292
- signature += 'B' ;
3293
- } ) ;
3294
- $animate . removeClass ( element , 'on' , function ( ) {
3295
- signature += 'C' ;
3296
- } ) ;
3250
+ $animate . triggerReflow ( ) ;
3297
3251
3298
3252
$timeout . flush ( 1 ) ;
3299
- expect ( signature ) . toBe ( 'AB ' ) ;
3253
+ expect ( signature ) . toBe ( 'A ' ) ;
3300
3254
3301
- $animate . triggerReflow ( ) ;
3302
3255
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) , elapsedTime : 2000 } ) ;
3303
3256
$timeout . flush ( 1 ) ;
3304
3257
3305
- expect ( signature ) . toBe ( 'ABC ' ) ;
3258
+ expect ( signature ) . toBe ( 'AB ' ) ;
3306
3259
} ) ) ;
3307
3260
} ) ;
3308
3261
} ) ;
0 commit comments