@@ -61,38 +61,79 @@ asyncTest( "animateClass works with borderStyle", function() {
6161
6262asyncTest ( "animateClass works with colors" , function ( ) {
6363 var test = $ ( "div.animateClass" ) ,
64- count = 0 ;
64+ count = 0 ,
65+ oldStep = jQuery . fx . step . backgroundColor ;
6566 expect ( 2 ) ;
66- test . toggleClass ( "testChangeBackground" , duration , function ( ) {
67- present ( test . css ( "backgroundColor" ) , [ "#ffffff" , "#fff" , "rgb(255, 255, 255)" ] , "Color is final" ) ;
68- start ( ) ;
67+
68+ // we want to catch the first frame of animation
69+ jQuery . fx . step . backgroundColor = function ( fx ) {
70+ oldStep . apply ( this , arguments ) ;
71+
72+ // make sure it has animated somewhere we can detect
73+ if ( fx . pos > 255 / 2000 ) {
74+ jQuery . fx . step . backgroundColor = oldStep ;
75+ notPresent ( test . css ( "backgroundColor" ) ,
76+ [ "#000000" , "#ffffff" , "#000" , "#fff" , "rgb(0, 0, 0)" , "rgb(255,255,255)" ] ,
77+ "Color is not endpoints in middle." ) ;
78+ test . stop ( true , true ) ;
79+ }
80+ } ;
81+
82+ test . toggleClass ( "testChangeBackground" , {
83+ duration : 2000 ,
84+ complete : function ( ) {
85+ present ( test . css ( "backgroundColor" ) , [ "#ffffff" , "#fff" , "rgb(255, 255, 255)" ] , "Color is final" ) ;
86+ start ( ) ;
87+ }
6988 } ) ;
70- setTimeout ( function ( ) {
71- var color = test . css ( "backgroundColor" ) ;
72- notPresent ( color , [ "#000000" , "#ffffff" , "#000" , "#fff" , "rgb(0, 0, 0)" , "rgb(255,255,255)" ] ,
73- "Color is not endpoints in middle." ) ;
74- } , mid ) ;
7589} ) ;
7690
77- asyncTest ( "animateClass works with children" , function ( ) {
78- var test = $ ( "div.animateClass" ) ,
79- h2 = test . find ( "h2" ) ;
91+ asyncTest ( "animateClass calls step option" , 1 , function ( ) {
92+ var test = jQuery ( "div.animateClass" ) ,
93+ done = function ( ) {
94+ done = jQuery . noop ;
95+ test . stop ( ) ;
96+ start ( ) ;
97+ } ;
98+ test . toggleClass ( "testChangeBackground" , {
99+ step : function ( fx ) {
100+ ok ( true , "Step Function Called" ) ;
101+ setTimeout ( done , 0 ) ;
102+ }
103+ } ) ;
104+ } ) ;
80105
81- expect ( 4 ) ;
82- setTimeout ( function ( ) {
83- notPresent ( h2 . css ( "fontSize" ) , [ "10px" , "20px" ] , "Font size is neither endpoint when in middle." ) ;
84- } , mid ) ;
85- test . toggleClass ( "testChildren" , { children : true , duration : duration , complete : function ( ) {
86- equal ( h2 . css ( "fontSize" ) , "20px" , "Text size is final during complete" ) ;
87- test . toggleClass ( "testChildren" , duration , function ( ) {
88- equal ( h2 . css ( "fontSize" ) , "10px" , "Text size revertted after class removed" ) ;
106+ asyncTest ( "animateClass works with children" , 3 , function ( ) {
107+ var animatedChild ,
108+ test = $ ( "div.animateClass" ) ,
109+ h2 = test . find ( "h2" ) ;
89110
90- start ( ) ;
91- } ) ;
92- setTimeout ( function ( ) {
93- equal ( h2 . css ( "fontSize" ) , "20px" , "Text size unchanged during animate with children: undefined" ) ;
94- } , mid ) ;
95- } } ) ;
111+ test . toggleClass ( "testChildren" , {
112+ children : true ,
113+ duration : duration ,
114+ complete : function ( ) {
115+ equal ( h2 . css ( "fontSize" ) , "20px" , "Text size is final during complete" ) ;
116+ test . toggleClass ( "testChildren" , {
117+ duration : duration ,
118+ complete : function ( ) {
119+ equal ( h2 . css ( "fontSize" ) , "10px" , "Text size revertted after class removed" ) ;
120+
121+ start ( ) ;
122+ } ,
123+ step : function ( val , fx ) {
124+ if ( fx . elem === h2 [ 0 ] ) {
125+ ok ( false , "Error - Animating property on h2" ) ;
126+ }
127+ }
128+ } ) ;
129+ } ,
130+ step : function ( val , fx ) {
131+ if ( fx . prop === "fontSize" && fx . elem === h2 [ 0 ] && ! animatedChild ) {
132+ equal ( fx . end , 20 , "animating font size on child" ) ;
133+ animatedChild = true ;
134+ }
135+ }
136+ } ) ;
96137} ) ;
97138
98139asyncTest ( "animateClass clears style properties when stopped" , function ( ) {
0 commit comments