@@ -1671,11 +1671,13 @@ describe("ngAnimate $animateCss", function() {
1671
1671
1672
1672
describe ( "options" , function ( ) {
1673
1673
var element ;
1674
- beforeEach ( inject ( function ( $rootElement , $$body ) {
1675
- $$body . append ( $rootElement ) ;
1674
+ beforeEach ( module ( function ( ) {
1675
+ return function ( $rootElement , $$body ) {
1676
+ $$body . append ( $rootElement ) ;
1676
1677
1677
- element = jqLite ( '<div></div>' ) ;
1678
- $rootElement . append ( element ) ;
1678
+ element = jqLite ( '<div></div>' ) ;
1679
+ $rootElement . append ( element ) ;
1680
+ } ;
1679
1681
} ) ) ;
1680
1682
1681
1683
describe ( "[$$skipPreparationClasses]" , function ( ) {
@@ -1862,7 +1864,6 @@ describe("ngAnimate $animateCss", function() {
1862
1864
animator . start ( ) ;
1863
1865
triggerAnimationStartFrame ( ) ;
1864
1866
1865
-
1866
1867
var prop = element . css ( 'transition-delay' ) ;
1867
1868
expect ( prop ) . toEqual ( '500s' ) ;
1868
1869
} ) ) ;
@@ -1978,6 +1979,53 @@ describe("ngAnimate $animateCss", function() {
1978
1979
expect ( element . css ( 'transition-delay' ) ) . toEqual ( '10s' ) ;
1979
1980
} ) ) ;
1980
1981
1982
+ it ( "should apply the keyframe and transition duration value before the CSS classes are applied" , function ( ) {
1983
+ var classSpy = jasmine . createSpy ( ) ;
1984
+ module ( function ( $provide ) {
1985
+ $provide . value ( '$$jqLite' , {
1986
+ addClass : function ( ) {
1987
+ classSpy ( ) ;
1988
+ } ,
1989
+ removeClass : function ( ) {
1990
+ classSpy ( ) ;
1991
+ }
1992
+ } ) ;
1993
+ } ) ;
1994
+ inject ( function ( $animateCss , $rootElement ) {
1995
+ element . addClass ( 'element' ) ;
1996
+ ss . addRule ( '.element' , '-webkit-animation:3s keyframe_animation;' +
1997
+ 'animation:3s keyframe_animation;' +
1998
+ 'transition:5s linear all;' ) ;
1999
+
2000
+ var options = {
2001
+ delay : 2 ,
2002
+ duration : 2 ,
2003
+ addClass : 'superman' ,
2004
+ $$skipPreparationClasses : true ,
2005
+ structural : true
2006
+ } ;
2007
+ var animator = $animateCss ( element , options ) ;
2008
+
2009
+ expect ( element . attr ( 'style' ) || '' ) . not . toContain ( 'animation-delay' ) ;
2010
+ expect ( element . attr ( 'style' ) || '' ) . not . toContain ( 'transition-delay' ) ;
2011
+ expect ( classSpy ) . not . toHaveBeenCalled ( ) ;
2012
+
2013
+ //redefine the classSpy to assert that the delay values have been
2014
+ //applied before the classes are added
2015
+ var assertionsRun = false ;
2016
+ classSpy = function ( ) {
2017
+ assertionsRun = true ;
2018
+ expect ( element . css ( prefix + 'animation-delay' ) ) . toEqual ( '2s' ) ;
2019
+ expect ( element . css ( 'transition-delay' ) ) . toEqual ( '2s' ) ;
2020
+ expect ( element ) . not . toHaveClass ( 'superman' ) ;
2021
+ } ;
2022
+
2023
+ animator . start ( ) ;
2024
+ triggerAnimationStartFrame ( ) ;
2025
+ expect ( assertionsRun ) . toBe ( true ) ;
2026
+ } ) ;
2027
+ } ) ;
2028
+
1981
2029
it ( "should apply blocking before the animation starts, but then apply the detected delay when options.delay is true" ,
1982
2030
inject ( function ( $animateCss , $rootElement ) {
1983
2031
@@ -1995,41 +2043,28 @@ describe("ngAnimate $animateCss", function() {
1995
2043
animator . start ( ) ;
1996
2044
triggerAnimationStartFrame ( ) ;
1997
2045
1998
- expect ( element . css ( 'transition-delay' ) ) . toEqual ( '1s ') ;
2046
+ expect ( element . attr ( 'style' ) || '' ) . not . toContain ( 'transition-delay ') ;
1999
2047
} ) ) ;
2000
2048
2001
- they ( "should consider a negative value when delay:true is used with a $prop animation" , {
2002
- 'transition' : function ( ) {
2003
- return {
2004
- prop : 'transition-delay' ,
2005
- css : 'transition:2s linear all; transition-delay: -1s'
2006
- } ;
2007
- } ,
2008
- 'keyframe' : function ( prefix ) {
2009
- return {
2010
- prop : prefix + 'animation-delay' ,
2011
- css : prefix + 'animation:2s keyframe_animation; ' + prefix + 'animation-delay: -1s;'
2012
- } ;
2013
- }
2014
- } , function ( testDetailsFactory ) {
2049
+ it ( "should consider a negative value when delay:true is used with a keyframe animation" ,
2015
2050
inject ( function ( $animateCss , $rootElement ) {
2016
- var testDetails = testDetailsFactory ( prefix ) ;
2017
2051
2018
- ss . addRule ( '.ng-enter' , testDetails . css ) ;
2019
- var options = {
2020
- delay : true ,
2021
- event : 'enter' ,
2022
- structural : true
2023
- } ;
2052
+ ss . addRule ( '.ng-enter' , prefix + 'animation:2s keyframe_animation; ' +
2053
+ prefix + 'animation-delay: -1s;' ) ;
2024
2054
2025
- var animator = $animateCss ( element , options ) ;
2055
+ var options = {
2056
+ delay : true ,
2057
+ event : 'enter' ,
2058
+ structural : true
2059
+ } ;
2026
2060
2027
- animator . start ( ) ;
2028
- triggerAnimationStartFrame ( ) ;
2061
+ var animator = $animateCss ( element , options ) ;
2029
2062
2030
- expect ( element . css ( testDetails . prop ) ) . toContain ( '-1s' ) ;
2031
- } ) ;
2032
- } ) ;
2063
+ animator . start ( ) ;
2064
+ triggerAnimationStartFrame ( ) ;
2065
+
2066
+ expect ( element . css ( prefix + 'animation-delay' ) ) . toContain ( '-1s' ) ;
2067
+ } ) ) ;
2033
2068
2034
2069
they ( "should consider a negative value when a negative option delay is provided for a $prop animation" , {
2035
2070
'transition' : function ( ) {
0 commit comments