@@ -2137,5 +2137,71 @@ describe("animations", function() {
2137
2137
} ) ;
2138
2138
} ) ;
2139
2139
2140
+ describe ( 'when animations are skipped' , function ( ) {
2141
+
2142
+ var overriddenAnimationRunner ;
2143
+ var capturedAnimation ;
2144
+ var capturedAnimationHistory ;
2145
+ var defaultFakeAnimationRunner ;
2146
+ var parent ;
2147
+ var parent2 ;
2148
+
2149
+ beforeEach ( module ( function ( $provide ) {
2150
+ overriddenAnimationRunner = null ;
2151
+ capturedAnimation = null ;
2152
+ capturedAnimationHistory = [ ] ;
2153
+
2154
+ $provide . value ( '$$animation' , function ( ) {
2155
+ capturedAnimationHistory . push ( capturedAnimation = arguments ) ;
2156
+ return overriddenAnimationRunner || defaultFakeAnimationRunner ;
2157
+ } ) ;
2158
+
2159
+ return function ( $rootElement , $q , $animate , $$AnimateRunner , $document ) {
2160
+ defaultFakeAnimationRunner = new $$AnimateRunner ( ) ;
2161
+ $animate . enabled ( true ) ;
2162
+
2163
+ element = jqLite ( '<div class="element">element</div>' ) ;
2164
+ parent = jqLite ( '<div class="parent1">parent</div>' ) ;
2165
+ parent2 = jqLite ( '<div class="parent2">parent</div>' ) ;
2166
+
2167
+ $rootElement . append ( parent ) ;
2168
+ $rootElement . append ( parent2 ) ;
2169
+ jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
2170
+ } ;
2171
+ } ) ) ;
2172
+
2173
+
2174
+ it ( 'should trigger all callbacks if a follow-up structural animation takes over a running animation' ,
2175
+ inject ( function ( $animate , $rootScope ) {
2176
+
2177
+ parent . append ( element ) ;
2178
+ var moveSpy = jasmine . createSpy ( ) ;
2179
+ var leaveSpy = jasmine . createSpy ( ) ;
2180
+
2181
+ $animate . on ( 'move' , parent2 , moveSpy ) ;
2182
+ $animate . on ( 'leave' , parent2 , leaveSpy ) ;
2183
+
2184
+ $animate . move ( element , parent2 ) ;
2185
+
2186
+ $rootScope . $digest ( ) ;
2187
+ $animate . flush ( ) ;
2188
+
2189
+ expect ( moveSpy . callCount ) . toBe ( 1 ) ;
2190
+ expect ( moveSpy . calls [ 0 ] . args [ 1 ] ) . toBe ( 'start' ) ;
2191
+
2192
+ $animate . leave ( element ) ;
2193
+ $rootScope . $digest ( ) ;
2194
+ $animate . flush ( ) ;
2195
+
2196
+ expect ( moveSpy . callCount ) . toBe ( 2 ) ;
2197
+ expect ( moveSpy . calls [ 1 ] . args [ 1 ] ) . toBe ( 'close' ) ;
2198
+
2199
+ expect ( leaveSpy . callCount ) . toBe ( 2 ) ;
2200
+ expect ( leaveSpy . calls [ 0 ] . args [ 1 ] ) . toBe ( 'start' ) ;
2201
+ expect ( leaveSpy . calls [ 1 ] . args [ 1 ] ) . toBe ( 'close' ) ;
2202
+ } ) ) ;
2203
+
2204
+ } ) ;
2205
+
2140
2206
} ) ;
2141
2207
} ) ;
0 commit comments