3
3
describe ( "ngAnimate $$animateJs" , function ( ) {
4
4
5
5
beforeEach ( module ( 'ngAnimate' ) ) ;
6
+ beforeEach ( module ( 'ngAnimateMock' ) ) ;
6
7
7
8
function getDoneFunction ( args ) {
8
9
for ( var i = 1 ; i < args . length ; i ++ ) {
@@ -86,7 +87,7 @@ describe("ngAnimate $$animateJs", function() {
86
87
$animateProvider . register ( '.two' , makeAnimation ( 'enter' ) ) ;
87
88
$animateProvider . register ( '.three' , makeAnimation ( 'enter' ) ) ;
88
89
} ) ;
89
- inject ( function ( $$animateJs , $$rAF ) {
90
+ inject ( function ( $$animateJs , $animate ) {
90
91
var element = jqLite ( '<div class="one two three"></div>' ) ;
91
92
var animator = $$animateJs ( element , 'enter' ) ;
92
93
var complete = false ;
@@ -97,7 +98,7 @@ describe("ngAnimate $$animateJs", function() {
97
98
forEach ( doneCallbacks , function ( cb ) {
98
99
cb ( ) ;
99
100
} ) ;
100
- $$rAF . flush ( ) ;
101
+ $animate . flush ( ) ;
101
102
expect ( complete ) . toBe ( true ) ;
102
103
} ) ;
103
104
} ) ;
@@ -206,7 +207,7 @@ describe("ngAnimate $$animateJs", function() {
206
207
} ;
207
208
} ) ;
208
209
} ) ;
209
- inject ( function ( $$animateJs , $$rAF ) {
210
+ inject ( function ( $$animateJs , $animate ) {
210
211
var element = jqLite ( '<div class="the-end"></div>' ) ;
211
212
var animator = $$animateJs ( element , 'addClass' , {
212
213
addClass : 'red'
@@ -221,12 +222,12 @@ describe("ngAnimate $$animateJs", function() {
221
222
before ( ) ;
222
223
223
224
expect ( after ) . toBeUndefined ( ) ;
224
- $$rAF . flush ( ) ;
225
+ $animate . flush ( ) ;
225
226
expect ( after ) . toBeDefined ( ) ;
226
227
after ( ) ;
227
228
228
229
expect ( endCalled ) . toBeUndefined ( ) ;
229
- $$rAF . flush ( ) ;
230
+ $animate . flush ( ) ;
230
231
expect ( endCalled ) . toBe ( true ) ;
231
232
} ) ;
232
233
} ) ;
@@ -251,7 +252,7 @@ describe("ngAnimate $$animateJs", function() {
251
252
} ;
252
253
} ) ;
253
254
} ) ;
254
- inject ( function ( $$animateJs , $$rAF ) {
255
+ inject ( function ( $$animateJs , $animate ) {
255
256
var element = jqLite ( '<div class="the-end"></div>' ) ;
256
257
var animator = $$animateJs ( element , 'addClass' , {
257
258
domOperation : function ( ) {
@@ -264,7 +265,7 @@ describe("ngAnimate $$animateJs", function() {
264
265
} ) ;
265
266
runner [ method ] ( ) ;
266
267
267
- $$rAF . flush ( ) ;
268
+ $animate . flush ( ) ;
268
269
expect ( log ) . toEqual (
269
270
[ 'before addClass ' + method ,
270
271
'dom addClass' ,
@@ -278,7 +279,7 @@ describe("ngAnimate $$animateJs", function() {
278
279
return { beforeAddClass : noop } ;
279
280
} ) ;
280
281
} ) ;
281
- inject ( function ( $$animateJs , $$rAF , $rootScope ) {
282
+ inject ( function ( $$animateJs , $animate , $rootScope ) {
282
283
var element = jqLite ( '<div class="the-end"></div>' ) ;
283
284
var animator = $$animateJs ( element , 'addClass' ) ;
284
285
var runner = animator . start ( ) ;
@@ -291,7 +292,7 @@ describe("ngAnimate $$animateJs", function() {
291
292
} ) ;
292
293
293
294
runner . end ( ) ;
294
- $$rAF . flush ( ) ;
295
+ $animate . flush ( ) ;
295
296
$rootScope . $digest ( ) ;
296
297
expect ( done ) . toBe ( true ) ;
297
298
expect ( cancelled ) . toBe ( false ) ;
@@ -304,7 +305,7 @@ describe("ngAnimate $$animateJs", function() {
304
305
return { beforeAddClass : noop } ;
305
306
} ) ;
306
307
} ) ;
307
- inject ( function ( $$animateJs , $$rAF , $rootScope ) {
308
+ inject ( function ( $$animateJs , $animate , $rootScope ) {
308
309
var element = jqLite ( '<div class="the-end"></div>' ) ;
309
310
var animator = $$animateJs ( element , 'addClass' ) ;
310
311
var runner = animator . start ( ) ;
@@ -317,7 +318,7 @@ describe("ngAnimate $$animateJs", function() {
317
318
} ) ;
318
319
319
320
runner . cancel ( ) ;
320
- $$rAF . flush ( ) ;
321
+ $animate . flush ( ) ;
321
322
$rootScope . $digest ( ) ;
322
323
expect ( done ) . toBe ( false ) ;
323
324
expect ( cancelled ) . toBe ( true ) ;
@@ -504,7 +505,7 @@ describe("ngAnimate $$animateJs", function() {
504
505
var allEvents = [ 'leave' ] . concat ( otherEvents ) . concat ( enterMoveEvents ) ;
505
506
506
507
they ( "$prop should asynchronously render the before$prop animation" , otherEvents , function ( event ) {
507
- inject ( function ( $$rAF ) {
508
+ inject ( function ( $animate ) {
508
509
var beforeMethod = 'before' + event . charAt ( 0 ) . toUpperCase ( ) + event . substr ( 1 ) ;
509
510
animations [ beforeMethod ] = function ( element , a , b , c ) {
510
511
log . push ( 'before ' + event ) ;
@@ -514,14 +515,14 @@ describe("ngAnimate $$animateJs", function() {
514
515
515
516
runAnimation ( event ) ;
516
517
expect ( log ) . toEqual ( [ 'before ' + event ] ) ;
517
- $$rAF . flush ( ) ;
518
+ $animate . flush ( ) ;
518
519
519
520
expect ( log ) . toEqual ( [ 'before ' + event , 'dom ' + event ] ) ;
520
521
} ) ;
521
522
} ) ;
522
523
523
524
they ( "$prop should asynchronously render the $prop animation" , allEvents , function ( event ) {
524
- inject ( function ( $$rAF ) {
525
+ inject ( function ( $animate ) {
525
526
animations [ event ] = function ( element , a , b , c ) {
526
527
log . push ( 'after ' + event ) ;
527
528
var done = getDoneFunction ( arguments ) ;
@@ -534,11 +535,11 @@ describe("ngAnimate $$animateJs", function() {
534
535
535
536
if ( event === 'leave' ) {
536
537
expect ( log ) . toEqual ( [ 'after leave' ] ) ;
537
- $$rAF . flush ( ) ;
538
+ $animate . flush ( ) ;
538
539
expect ( log ) . toEqual ( [ 'after leave' , 'dom leave' , 'complete' ] ) ;
539
540
} else {
540
541
expect ( log ) . toEqual ( [ 'dom ' + event , 'after ' + event ] ) ;
541
- $$rAF . flush ( ) ;
542
+ $animate . flush ( ) ;
542
543
expect ( log ) . toEqual ( [ 'dom ' + event , 'after ' + event , 'complete' ] ) ;
543
544
}
544
545
} ) ;
@@ -547,7 +548,7 @@ describe("ngAnimate $$animateJs", function() {
547
548
they ( "$prop should asynchronously render the $prop animation when a start/end animator object is returned" ,
548
549
allEvents , function ( event ) {
549
550
550
- inject ( function ( $$rAF , $$AnimateRunner ) {
551
+ inject ( function ( $animate , $$AnimateRunner ) {
551
552
var runner ;
552
553
animations [ event ] = function ( element , a , b , c ) {
553
554
return {
@@ -565,12 +566,12 @@ describe("ngAnimate $$animateJs", function() {
565
566
if ( event === 'leave' ) {
566
567
expect ( log ) . toEqual ( [ 'start leave' ] ) ;
567
568
runner . end ( ) ;
568
- $$rAF . flush ( ) ;
569
+ $animate . flush ( ) ;
569
570
expect ( log ) . toEqual ( [ 'start leave' , 'dom leave' , 'complete' ] ) ;
570
571
} else {
571
572
expect ( log ) . toEqual ( [ 'dom ' + event , 'start ' + event ] ) ;
572
573
runner . end ( ) ;
573
- $$rAF . flush ( ) ;
574
+ $animate . flush ( ) ;
574
575
expect ( log ) . toEqual ( [ 'dom ' + event , 'start ' + event , 'complete' ] ) ;
575
576
}
576
577
} ) ;
@@ -579,7 +580,7 @@ describe("ngAnimate $$animateJs", function() {
579
580
they ( "$prop should asynchronously render the $prop animation when an instance of $$AnimateRunner is returned" ,
580
581
allEvents , function ( event ) {
581
582
582
- inject ( function ( $$rAF , $$AnimateRunner ) {
583
+ inject ( function ( $animate , $$AnimateRunner ) {
583
584
var runner ;
584
585
animations [ event ] = function ( element , a , b , c ) {
585
586
log . push ( 'start ' + event ) ;
@@ -593,19 +594,19 @@ describe("ngAnimate $$animateJs", function() {
593
594
if ( event === 'leave' ) {
594
595
expect ( log ) . toEqual ( [ 'start leave' ] ) ;
595
596
runner . end ( ) ;
596
- $$rAF . flush ( ) ;
597
+ $animate . flush ( ) ;
597
598
expect ( log ) . toEqual ( [ 'start leave' , 'dom leave' , 'complete' ] ) ;
598
599
} else {
599
600
expect ( log ) . toEqual ( [ 'dom ' + event , 'start ' + event ] ) ;
600
601
runner . end ( ) ;
601
- $$rAF . flush ( ) ;
602
+ $animate . flush ( ) ;
602
603
expect ( log ) . toEqual ( [ 'dom ' + event , 'start ' + event , 'complete' ] ) ;
603
604
}
604
605
} ) ;
605
606
} ) ;
606
607
607
608
they ( "$prop should asynchronously reject the before animation if the callback function is called with false" , otherEvents , function ( event ) {
608
- inject ( function ( $$rAF , $rootScope ) {
609
+ inject ( function ( $animate , $rootScope ) {
609
610
var beforeMethod = 'before' + event . charAt ( 0 ) . toUpperCase ( ) + event . substr ( 1 ) ;
610
611
animations [ beforeMethod ] = function ( element , a , b , c ) {
611
612
log . push ( 'before ' + event ) ;
@@ -624,13 +625,13 @@ describe("ngAnimate $$animateJs", function() {
624
625
function ( ) { log . push ( 'fail' ) ; } ) ;
625
626
626
627
expect ( log ) . toEqual ( [ 'before ' + event ] ) ;
627
- $$rAF . flush ( ) ;
628
+ $animate . flush ( ) ;
628
629
expect ( log ) . toEqual ( [ 'before ' + event , 'dom ' + event , 'fail' ] ) ;
629
630
} ) ;
630
631
} ) ;
631
632
632
633
they ( "$prop should asynchronously reject the after animation if the callback function is called with false" , allEvents , function ( event ) {
633
- inject ( function ( $$rAF , $rootScope ) {
634
+ inject ( function ( $animate , $rootScope ) {
634
635
animations [ event ] = function ( element , a , b , c ) {
635
636
log . push ( 'after ' + event ) ;
636
637
var done = getDoneFunction ( arguments ) ;
@@ -644,17 +645,17 @@ describe("ngAnimate $$animateJs", function() {
644
645
var expectations = [ ] ;
645
646
if ( event === 'leave' ) {
646
647
expect ( log ) . toEqual ( [ 'after leave' ] ) ;
647
- $$rAF . flush ( ) ;
648
+ $animate . flush ( ) ;
648
649
expect ( log ) . toEqual ( [ 'after leave' , 'dom leave' , 'fail' ] ) ;
649
650
} else {
650
651
expect ( log ) . toEqual ( [ 'dom ' + event , 'after ' + event ] ) ;
651
- $$rAF . flush ( ) ;
652
+ $animate . flush ( ) ;
652
653
expect ( log ) . toEqual ( [ 'dom ' + event , 'after ' + event , 'fail' ] ) ;
653
654
}
654
655
} ) ;
655
656
} ) ;
656
657
657
- it ( 'setClass should delegate down to addClass/removeClass if not defined' , inject ( function ( $$rAF ) {
658
+ it ( 'setClass should delegate down to addClass/removeClass if not defined' , inject ( function ( $animate ) {
658
659
animations . addClass = function ( element , done ) {
659
660
log . push ( 'addClass' ) ;
660
661
} ;
@@ -671,7 +672,7 @@ describe("ngAnimate $$animateJs", function() {
671
672
} ) ) ;
672
673
673
674
it ( 'beforeSetClass should delegate down to beforeAddClass/beforeRemoveClass if not defined' ,
674
- inject ( function ( $$rAF ) {
675
+ inject ( function ( $animate ) {
675
676
676
677
animations . beforeAddClass = function ( element , className , done ) {
677
678
log . push ( 'beforeAddClass' ) ;
@@ -686,13 +687,13 @@ describe("ngAnimate $$animateJs", function() {
686
687
expect ( animations . setClass ) . toBeFalsy ( ) ;
687
688
688
689
runAnimation ( 'setClass' ) ;
689
- $$rAF . flush ( ) ;
690
+ $animate . flush ( ) ;
690
691
691
692
expect ( log ) . toEqual ( [ 'beforeRemoveClass' , 'beforeAddClass' , 'dom setClass' ] ) ;
692
693
} ) ) ;
693
694
694
695
it ( 'leave should always ignore the `beforeLeave` animation' ,
695
- inject ( function ( $$rAF ) {
696
+ inject ( function ( $animate ) {
696
697
697
698
animations . beforeLeave = function ( element , done ) {
698
699
log . push ( 'beforeLeave' ) ;
@@ -705,13 +706,13 @@ describe("ngAnimate $$animateJs", function() {
705
706
} ;
706
707
707
708
runAnimation ( 'leave' ) ;
708
- $$rAF . flush ( ) ;
709
+ $animate . flush ( ) ;
709
710
710
711
expect ( log ) . toEqual ( [ 'leave' , 'dom leave' ] ) ;
711
712
} ) ) ;
712
713
713
714
it ( 'should allow custom events to be triggered' ,
714
- inject ( function ( $$rAF ) {
715
+ inject ( function ( $animate ) {
715
716
716
717
animations . beforeFlex = function ( element , done ) {
717
718
log . push ( 'beforeFlex' ) ;
@@ -724,7 +725,7 @@ describe("ngAnimate $$animateJs", function() {
724
725
} ;
725
726
726
727
runAnimation ( 'flex' ) ;
727
- $$rAF . flush ( ) ;
728
+ $animate . flush ( ) ;
728
729
729
730
expect ( log ) . toEqual ( [ 'beforeFlex' , 'dom flex' , 'flex' ] ) ;
730
731
} ) ) ;
0 commit comments