@@ -25,6 +25,7 @@ describe('ngAnimate integration tests', function() {
25
25
ss . destroy ( ) ;
26
26
} ) ;
27
27
28
+
28
29
it ( 'should cancel a running and started removeClass animation when a follow-up addClass animation adds the same class' ,
29
30
inject ( function ( $animate , $rootScope , $$rAF , $document , $rootElement ) {
30
31
@@ -362,6 +363,7 @@ describe('ngAnimate integration tests', function() {
362
363
} ) ;
363
364
} ) ;
364
365
366
+
365
367
it ( 'should add the preparation class for an enter animation before a parent class-based animation is applied' , function ( ) {
366
368
module ( 'ngAnimateMock' ) ;
367
369
inject ( function ( $animate , $compile , $rootScope , $rootElement , $document ) {
@@ -397,6 +399,7 @@ describe('ngAnimate integration tests', function() {
397
399
} ) ;
398
400
} ) ;
399
401
402
+
400
403
it ( 'should avoid adding the ng-enter-prepare method to a parent structural animation that contains child animations' , function ( ) {
401
404
module ( 'ngAnimateMock' ) ;
402
405
inject ( function ( $animate , $compile , $rootScope , $rootElement , $document , $$rAF ) {
@@ -468,6 +471,84 @@ describe('ngAnimate integration tests', function() {
468
471
} ) ;
469
472
} ) ;
470
473
474
+
475
+ it ( 'should remove the prepare classes when different structural animations happen in the same digest' , function ( ) {
476
+ module ( 'ngAnimateMock' ) ;
477
+ inject ( function ( $animate , $compile , $rootScope , $rootElement , $document , $$animateCache ) {
478
+ element = jqLite (
479
+ // Class animation on parent element is neeeded so the child elements get the prepare class
480
+ '<div id="outer" ng-class="{blue: cond}" ng-switch="cond">' +
481
+ '<div id="default" ng-switch-default></div>' +
482
+ '<div id="truthy" ng-switch-when="true"></div>' +
483
+ '</div>'
484
+ ) ;
485
+
486
+ $rootElement . append ( element ) ;
487
+ jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
488
+
489
+ $compile ( element ) ( $rootScope ) ;
490
+ $rootScope . cond = false ;
491
+ $rootScope . $digest ( ) ;
492
+
493
+ $rootScope . cond = true ;
494
+ $rootScope . $digest ( ) ;
495
+
496
+ var parent = element ;
497
+ var truthySwitch = jqLite ( parent [ 0 ] . querySelector ( '#truthy' ) ) ;
498
+ var defaultSwitch = jqLite ( parent [ 0 ] . querySelector ( '#default' ) ) ;
499
+
500
+ expect ( parent ) . not . toHaveClass ( 'blue' ) ;
501
+ expect ( parent ) . toHaveClass ( 'blue-add' ) ;
502
+ expect ( truthySwitch ) . toHaveClass ( 'ng-enter-prepare' ) ;
503
+ expect ( defaultSwitch ) . toHaveClass ( 'ng-leave-prepare' ) ;
504
+
505
+ $animate . flush ( ) ;
506
+
507
+ expect ( parent ) . toHaveClass ( 'blue' ) ;
508
+ expect ( parent ) . not . toHaveClass ( 'blue-add' ) ;
509
+ expect ( truthySwitch ) . not . toHaveClass ( 'ng-enter-prepare' ) ;
510
+ expect ( defaultSwitch ) . not . toHaveClass ( 'ng-leave-prepare' ) ;
511
+ } ) ;
512
+ } ) ;
513
+
514
+ it ( 'should respect the element node for caching when animations with the same type happen in the same digest' , function ( ) {
515
+ module ( 'ngAnimateMock' ) ;
516
+ inject ( function ( $animate , $compile , $rootScope , $rootElement , $document , $$animateCache ) {
517
+ ss . addRule ( '.animate.ng-enter' , 'transition:2s linear all;' ) ;
518
+
519
+ element = jqLite (
520
+ '<div>' +
521
+ '<div>' +
522
+ '<div id="noanimate" ng-if="cond"></div>' +
523
+ '</div>' +
524
+ '<div>' +
525
+ '<div id="animate" class="animate" ng-if="cond"></div>' +
526
+ '</div>' +
527
+ '</div>'
528
+ ) ;
529
+
530
+ $rootElement . append ( element ) ;
531
+ jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
532
+
533
+ $compile ( element ) ( $rootScope ) ;
534
+ $rootScope . cond = true ;
535
+ $rootScope . $digest ( ) ;
536
+
537
+ var parent = element ;
538
+ var noanimate = jqLite ( parent [ 0 ] . querySelector ( '#noanimate' ) ) ;
539
+ var animate = jqLite ( parent [ 0 ] . querySelector ( '#animate' ) ) ;
540
+
541
+ expect ( noanimate ) . not . toHaveClass ( 'ng-enter' ) ;
542
+ expect ( animate ) . toHaveClass ( 'ng-enter' ) ;
543
+
544
+ $animate . closeAndFlush ( ) ;
545
+
546
+ expect ( noanimate ) . not . toHaveClass ( 'ng-enter' ) ;
547
+ expect ( animate ) . not . toHaveClass ( 'ng-enter' ) ;
548
+ } ) ;
549
+ } ) ;
550
+
551
+
471
552
it ( 'should pack level elements into their own RAF flush' , function ( ) {
472
553
module ( 'ngAnimateMock' ) ;
473
554
inject ( function ( $animate , $compile , $rootScope , $rootElement , $document ) {
0 commit comments