@@ -783,9 +783,47 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
783
783
return queueFn ;
784
784
} ) ;
785
785
786
- $provide . decorator ( '$animate' , [ '$delegate' , '$timeout' , '$browser' , '$$rAF' ,
786
+ $provide . decorator ( '$$animateJs' , [ '$delegate' , function ( $delegate ) {
787
+ var runners = [ ] ;
788
+
789
+ var animateJsConstructor = function ( element , event , classes , options ) {
790
+ var animator = $delegate ( element , event , classes , options ) ;
791
+ runners . push ( animator ) ;
792
+ return animator ;
793
+ } ;
794
+
795
+ animateJsConstructor . $closeAndFlush = function ( ) {
796
+ runners . forEach ( function ( runner ) {
797
+ runner . end ( ) ;
798
+ } ) ;
799
+ runners = [ ] ;
800
+ } ;
801
+
802
+ return animateJsConstructor ;
803
+ } ] ) ;
804
+
805
+ $provide . decorator ( '$animateCss' , [ '$delegate' , function ( $delegate ) {
806
+ var runners = [ ] ;
807
+
808
+ var animateCssConstructor = function ( element , options ) {
809
+ var animator = $delegate ( element , options ) ;
810
+ runners . push ( animator ) ;
811
+ return animator ;
812
+ } ;
813
+
814
+ animateCssConstructor . $closeAndFlush = function ( ) {
815
+ runners . forEach ( function ( runner ) {
816
+ runner . end ( ) ;
817
+ } ) ;
818
+ runners = [ ] ;
819
+ } ;
820
+
821
+ return animateCssConstructor ;
822
+ } ] ) ;
823
+
824
+ $provide . decorator ( '$animate' , [ '$delegate' , '$timeout' , '$browser' , '$$rAF' , '$animateCss' , '$$animateJs' ,
787
825
'$$forceReflow' , '$$animateAsyncRun' , '$rootScope' ,
788
- function ( $delegate , $timeout , $browser , $$rAF ,
826
+ function ( $delegate , $timeout , $browser , $$rAF , $animateCss , $$animateJs ,
789
827
$$forceReflow , $$animateAsyncRun , $rootScope ) {
790
828
var animate = {
791
829
queue : [ ] ,
@@ -797,7 +835,13 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
797
835
return $$forceReflow . totalReflows ;
798
836
} ,
799
837
enabled : $delegate . enabled ,
800
- flush : function ( ) {
838
+ closeAndFlush : function ( ) {
839
+ this . flush ( true ) ;
840
+ $animateCss . $closeAndFlush ( ) ;
841
+ $$animateJs . $closeAndFlush ( ) ;
842
+ this . flush ( ) ;
843
+ } ,
844
+ flush : function ( hideErrors ) {
801
845
$rootScope . $digest ( ) ;
802
846
803
847
var doNextRun , somethingFlushed = false ;
@@ -814,7 +858,7 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
814
858
}
815
859
} while ( doNextRun ) ;
816
860
817
- if ( ! somethingFlushed ) {
861
+ if ( ! somethingFlushed && ! hideErrors ) {
818
862
throw new Error ( 'No pending animations ready to be closed or flushed' ) ;
819
863
}
820
864
0 commit comments