@@ -505,122 +505,121 @@ describe('ngView', function() {
505
505
} ) ;
506
506
} ) ;
507
507
} ) ;
508
- } ) ;
509
508
510
- describe ( 'ngAnimate' , function ( ) {
511
- var window ;
512
- var body , element ;
509
+ describe ( 'ngAnimate ' , function ( ) {
510
+ var window , vendorPrefix ;
511
+ var body , element ;
513
512
514
- function html ( html ) {
515
- body . html ( html ) ;
516
- element = body . children ( ) . eq ( 0 ) ;
517
- return element ;
518
- }
513
+ function html ( html ) {
514
+ body . html ( html ) ;
515
+ element = body . children ( ) . eq ( 0 ) ;
516
+ return element ;
517
+ }
519
518
520
- beforeEach ( function ( ) {
521
- // we need to run animation on attached elements;
522
- body = jqLite ( document . body ) ;
523
- } ) ;
519
+ function applyCSS ( element , cssProp , cssValue ) {
520
+ element . css ( cssProp , cssValue ) ;
521
+ element . css ( vendorPrefix + cssProp , cssValue ) ;
522
+ }
524
523
525
- afterEach ( function ( ) {
526
- dealoc ( body ) ;
527
- dealoc ( element ) ;
528
- } ) ;
524
+ beforeEach ( function ( ) {
525
+ // we need to run animation on attached elements ;
526
+ body = jqLite ( document . body ) ;
527
+ } ) ;
529
528
529
+ afterEach ( function ( ) {
530
+ dealoc ( body ) ;
531
+ dealoc ( element ) ;
532
+ } ) ;
530
533
531
534
532
- beforeEach ( module ( function ( $provide , $routeProvider ) {
533
- $provide . value ( '$window' , window = angular . mock . createMockWindow ( ) ) ;
534
- $routeProvider . when ( '/foo' , { controller : noop , templateUrl : '/foo.html' } ) ;
535
- return function ( $templateCache , $animator ) {
536
- $templateCache . put ( '/foo.html' , [ 200 , '<div>data</div>' , { } ] ) ;
537
- $animator . enabled ( true ) ;
538
- }
539
- } ) ) ;
535
+ beforeEach ( module ( function ( $provide , $routeProvider ) {
536
+ $provide . value ( '$window' , window = angular . mock . createMockWindow ( ) ) ;
537
+ $routeProvider . when ( '/foo' , { controller : noop , templateUrl : '/foo.html' } ) ;
538
+ return function ( $sniffer , $templateCache , $animator ) {
539
+ vendorPrefix = '-' + $sniffer . vendorPrefix + '-' ;
540
+ $templateCache . put ( '/foo.html' , [ 200 , '<div>data</div>' , { } ] ) ;
541
+ $animator . enabled ( true ) ;
542
+ }
543
+ } ) ) ;
540
544
541
- it ( 'should fire off the enter animation + add and remove the css classes' ,
542
- inject ( function ( $compile , $rootScope , $sniffer , $location , $templateCache ) {
543
- element = $compile ( html ( '<div ng-view ng-animate="{enter: \'custom-enter\'}"></div>' ) ) ( $rootScope ) ;
545
+ it ( 'should fire off the enter animation + add and remove the css classes' ,
546
+ inject ( function ( $compile , $rootScope , $sniffer , $location , $templateCache ) {
547
+ element = $compile ( html ( '<div ng-view ng-animate="{enter: \'custom-enter\'}"></div>' ) ) ( $rootScope ) ;
544
548
545
- $location . path ( '/foo' ) ;
546
- $rootScope . $digest ( ) ;
549
+ $location . path ( '/foo' ) ;
550
+ $rootScope . $digest ( ) ;
547
551
548
- //if we add the custom css stuff here then it will get picked up before the animation takes place
549
- var child = jqLite ( element . children ( ) [ 0 ] ) ;
550
- var cssProp = '-' + $sniffer . vendorPrefix + '-transition' ;
551
- var cssValue = '1s linear all' ;
552
- child . css ( cssProp , cssValue ) ;
552
+ //if we add the custom css stuff here then it will get picked up before the animation takes place
553
+ var child = jqLite ( element . children ( ) [ 0 ] ) ;
554
+ applyCSS ( child , 'transition' , '1s linear all' ) ;
553
555
554
- if ( $sniffer . supportsTransitions ) {
555
- expect ( child . attr ( 'class' ) ) . toContain ( 'custom-enter-setup' ) ;
556
- window . setTimeout . expect ( 1 ) . process ( ) ;
556
+ if ( $sniffer . supportsTransitions ) {
557
+ expect ( child . attr ( 'class' ) ) . toContain ( 'custom-enter-setup' ) ;
558
+ window . setTimeout . expect ( 1 ) . process ( ) ;
557
559
558
- expect ( child . attr ( 'class' ) ) . toContain ( 'custom-enter-start' ) ;
559
- window . setTimeout . expect ( 1000 ) . process ( ) ;
560
- } else {
561
- expect ( window . setTimeout . queue ) . toEqual ( [ ] ) ;
562
- }
560
+ expect ( child . attr ( 'class' ) ) . toContain ( 'custom-enter-start' ) ;
561
+ window . setTimeout . expect ( 1000 ) . process ( ) ;
562
+ } else {
563
+ expect ( window . setTimeout . queue ) . toEqual ( [ ] ) ;
564
+ }
563
565
564
- expect ( child . attr ( 'class' ) ) . not . toContain ( 'custom-enter-setup' ) ;
565
- expect ( child . attr ( 'class' ) ) . not . toContain ( 'custom-enter-start' ) ;
566
- } ) ) ;
566
+ expect ( child . attr ( 'class' ) ) . not . toContain ( 'custom-enter-setup' ) ;
567
+ expect ( child . attr ( 'class' ) ) . not . toContain ( 'custom-enter-start' ) ;
568
+ } ) ) ;
567
569
568
- it ( 'should fire off the leave animation + add and remove the css classes' ,
569
- inject ( function ( $compile , $rootScope , $sniffer , $location , $templateCache ) {
570
- $templateCache . put ( '/foo.html' , [ 200 , '<div>foo</div>' , { } ] ) ;
571
- element = $compile ( html ( '<div ng-view ng-animate="{leave: \'custom-leave\'}"></div>' ) ) ( $rootScope ) ;
570
+ it ( 'should fire off the leave animation + add and remove the css classes' ,
571
+ inject ( function ( $compile , $rootScope , $sniffer , $location , $templateCache ) {
572
+ $templateCache . put ( '/foo.html' , [ 200 , '<div>foo</div>' , { } ] ) ;
573
+ element = $compile ( html ( '<div ng-view ng-animate="{leave: \'custom-leave\'}"></div>' ) ) ( $rootScope ) ;
572
574
573
- $location . path ( '/foo' ) ;
574
- $rootScope . $digest ( ) ;
575
-
576
- //if we add the custom css stuff here then it will get picked up before the animation takes place
577
- var child = jqLite ( element . children ( ) [ 0 ] ) ;
578
- var cssProp = '-' + $sniffer . vendorPrefix + '-transition' ;
579
- var cssValue = '1s linear all' ;
580
- child . css ( cssProp , cssValue ) ;
575
+ $location . path ( '/foo' ) ;
576
+ $rootScope . $digest ( ) ;
581
577
582
- $location . path ( '/' ) ;
583
- $rootScope . $digest ( ) ;
578
+ //if we add the custom css stuff here then it will get picked up before the animation takes place
579
+ var child = jqLite ( element . children ( ) [ 0 ] ) ;
580
+ applyCSS ( child , 'transition' , '1s linear all' ) ;
584
581
585
- if ( $sniffer . supportsTransitions ) {
586
- expect ( child . attr ( 'class' ) ) . toContain ( 'custom-leave-setup' ) ;
587
- window . setTimeout . expect ( 1 ) . process ( ) ;
582
+ $location . path ( '/' ) ;
583
+ $rootScope . $digest ( ) ;
588
584
589
- expect ( child . attr ( 'class' ) ) . toContain ( 'custom-leave-start' ) ;
590
- window . setTimeout . expect ( 1000 ) . process ( ) ;
591
- } else {
592
- expect ( window . setTimeout . queue ) . toEqual ( [ ] ) ;
593
- }
585
+ if ( $sniffer . supportsTransitions ) {
586
+ expect ( child . attr ( 'class' ) ) . toContain ( 'custom-leave-setup' ) ;
587
+ window . setTimeout . expect ( 1 ) . process ( ) ;
588
+
589
+ expect ( child . attr ( 'class' ) ) . toContain ( 'custom-leave-start' ) ;
590
+ window . setTimeout . expect ( 1000 ) . process ( ) ;
591
+ } else {
592
+ expect ( window . setTimeout . queue ) . toEqual ( [ ] ) ;
593
+ }
594
+
595
+ expect ( child . attr ( 'class' ) ) . not . toContain ( 'custom-leave-setup' ) ;
596
+ expect ( child . attr ( 'class' ) ) . not . toContain ( 'custom-leave-start' ) ;
597
+ } ) ) ;
598
+
599
+ it ( 'should catch and use the correct duration for animations' ,
600
+ inject ( function ( $compile , $rootScope , $sniffer , $location , $templateCache ) {
601
+ $templateCache . put ( '/foo.html' , [ 200 , '<div>foo</div>' , { } ] ) ;
602
+ element = $compile ( html (
603
+ '<div ' +
604
+ 'ng-view ' +
605
+ 'ng-animate="{enter: \'customEnter\'}">' +
606
+ '</div>'
607
+ ) ) ( $rootScope ) ;
594
608
595
- expect ( child . attr ( 'class' ) ) . not . toContain ( 'custom-leave-setup' ) ;
596
- expect ( child . attr ( 'class' ) ) . not . toContain ( 'custom-leave-start' ) ;
597
- } ) ) ;
609
+ $location . path ( '/foo' ) ;
610
+ $rootScope . $digest ( ) ;
598
611
599
- it ( 'should catch and use the correct duration for animations' ,
600
- inject ( function ( $compile , $rootScope , $sniffer , $location , $templateCache ) {
601
- $templateCache . put ( '/foo.html' , [ 200 , '<div>foo</div>' , { } ] ) ;
602
- element = $compile ( html (
603
- '<div ' +
604
- 'ng-view ' +
605
- 'ng-animate="{enter: \'customEnter\'}">' +
606
- '</div>'
607
- ) ) ( $rootScope ) ;
608
-
609
- $location . path ( '/foo' ) ;
610
- $rootScope . $digest ( ) ;
612
+ //if we add the custom css stuff here then it will get picked up before the animation takes place
613
+ var child = jqLite ( element . children ( ) [ 0 ] ) ;
614
+ applyCSS ( child , 'transition' , '0.5s linear all' ) ;
611
615
612
- //if we add the custom css stuff here then it will get picked up before the animation takes place
613
- var child = jqLite ( element . children ( ) [ 0 ] ) ;
614
- var cssProp = '-' + $sniffer . vendorPrefix + '-transition' ;
615
- var cssValue = '0.5s linear all' ;
616
- child . css ( cssProp , cssValue ) ;
617
-
618
- if ( $sniffer . supportsTransitions ) {
619
- window . setTimeout . expect ( 1 ) . process ( ) ;
620
- window . setTimeout . expect ( $sniffer . supportsTransitions ? 500 : 0 ) . process ( ) ;
621
- } else {
622
- expect ( window . setTimeout . queue ) . toEqual ( [ ] ) ;
623
- }
624
- } ) ) ;
616
+ if ( $sniffer . supportsTransitions ) {
617
+ window . setTimeout . expect ( 1 ) . process ( ) ;
618
+ window . setTimeout . expect ( $sniffer . supportsTransitions ? 500 : 0 ) . process ( ) ;
619
+ } else {
620
+ expect ( window . setTimeout . queue ) . toEqual ( [ ] ) ;
621
+ }
622
+ } ) ) ;
625
623
626
- } ) ;
624
+ } ) ;
625
+ } ) ;
0 commit comments