@@ -2191,5 +2191,71 @@ describe("animations", function() {
2191
2191
} ) ;
2192
2192
} ) ;
2193
2193
2194
+ describe ( 'when animations are skipped' , function ( ) {
2195
+
2196
+ var overriddenAnimationRunner ;
2197
+ var capturedAnimation ;
2198
+ var capturedAnimationHistory ;
2199
+ var defaultFakeAnimationRunner ;
2200
+ var parent ;
2201
+ var parent2 ;
2202
+
2203
+ beforeEach ( module ( function ( $provide ) {
2204
+ overriddenAnimationRunner = null ;
2205
+ capturedAnimation = null ;
2206
+ capturedAnimationHistory = [ ] ;
2207
+
2208
+ $provide . value ( '$$animation' , function ( ) {
2209
+ capturedAnimationHistory . push ( capturedAnimation = arguments ) ;
2210
+ return overriddenAnimationRunner || defaultFakeAnimationRunner ;
2211
+ } ) ;
2212
+
2213
+ return function ( $rootElement , $q , $animate , $$AnimateRunner , $document ) {
2214
+ defaultFakeAnimationRunner = new $$AnimateRunner ( ) ;
2215
+ $animate . enabled ( true ) ;
2216
+
2217
+ element = jqLite ( '<div class="element">element</div>' ) ;
2218
+ parent = jqLite ( '<div class="parent1">parent</div>' ) ;
2219
+ parent2 = jqLite ( '<div class="parent2">parent</div>' ) ;
2220
+
2221
+ $rootElement . append ( parent ) ;
2222
+ $rootElement . append ( parent2 ) ;
2223
+ jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
2224
+ } ;
2225
+ } ) ) ;
2226
+
2227
+
2228
+ it ( 'should trigger all callbacks if a follow-up structural animation takes over a running animation' ,
2229
+ inject ( function ( $animate , $rootScope ) {
2230
+
2231
+ parent . append ( element ) ;
2232
+ var moveSpy = jasmine . createSpy ( ) ;
2233
+ var leaveSpy = jasmine . createSpy ( ) ;
2234
+
2235
+ $animate . on ( 'move' , parent2 , moveSpy ) ;
2236
+ $animate . on ( 'leave' , parent2 , leaveSpy ) ;
2237
+
2238
+ $animate . move ( element , parent2 ) ;
2239
+
2240
+ $rootScope . $digest ( ) ;
2241
+ $animate . flush ( ) ;
2242
+
2243
+ expect ( moveSpy . callCount ) . toBe ( 1 ) ;
2244
+ expect ( moveSpy . calls [ 0 ] . args [ 1 ] ) . toBe ( 'start' ) ;
2245
+
2246
+ $animate . leave ( element ) ;
2247
+ $rootScope . $digest ( ) ;
2248
+ $animate . flush ( ) ;
2249
+
2250
+ expect ( moveSpy . callCount ) . toBe ( 2 ) ;
2251
+ expect ( moveSpy . calls [ 1 ] . args [ 1 ] ) . toBe ( 'close' ) ;
2252
+
2253
+ expect ( leaveSpy . callCount ) . toBe ( 2 ) ;
2254
+ expect ( leaveSpy . calls [ 0 ] . args [ 1 ] ) . toBe ( 'start' ) ;
2255
+ expect ( leaveSpy . calls [ 1 ] . args [ 1 ] ) . toBe ( 'close' ) ;
2256
+ } ) ) ;
2257
+
2258
+ } ) ;
2259
+
2194
2260
} ) ;
2195
2261
} ) ;
0 commit comments