@@ -8,7 +8,14 @@ function notPresent( value, array, message ) {
8
8
QUnit . push ( jQuery . inArray ( value , array ) === - 1 , value , array , message ) ;
9
9
}
10
10
11
- var animateTime = 15 ;
11
+ // minDuration is used for "short" animate tests where we are only concerned about the final
12
+ var minDuration = 15 ,
13
+
14
+ // duration is used for "long" animates where we plan on testing properties during animation
15
+ duration = 200 ,
16
+
17
+ // mid is used for testing in the "middle" of the "duration" animations
18
+ mid = duration / 2 ;
12
19
13
20
module ( "effects.core" ) ;
14
21
@@ -31,16 +38,16 @@ $.each( $.effects.effect, function( effect ) {
31
38
test ++ ;
32
39
equal ( point , test , "Queue function fired in order" ) ;
33
40
if ( fn ) {
34
- fn ( ) ;
41
+ fn ( ) ;
35
42
} else {
36
- setTimeout ( next , animateTime ) ;
43
+ setTimeout ( next , minDuration ) ;
37
44
}
38
45
} ;
39
46
}
40
-
41
- hidden . queue ( queueTest ( ) ) . show ( effect , animateTime , queueTest ( function ( ) {
47
+
48
+ hidden . queue ( queueTest ( ) ) . show ( effect , minDuration , queueTest ( function ( ) {
42
49
equal ( hidden . css ( "display" ) , "block" , "Hidden is shown after .show(\"" + effect + "\", time)" ) ;
43
- } ) ) . queue ( queueTest ( ) ) . hide ( effect , animateTime , queueTest ( function ( ) {
50
+ } ) ) . queue ( queueTest ( ) ) . hide ( effect , minDuration , queueTest ( function ( ) {
44
51
equal ( hidden . css ( "display" ) , "none" , "Back to hidden after .hide(\"" + effect + "\", time)" ) ;
45
52
} ) ) . queue ( queueTest ( function ( next ) {
46
53
deepEqual ( hidden . queue ( ) , [ "inprogress" ] , "Only the inprogress sentinel remains" ) ;
@@ -55,8 +62,8 @@ asyncTest( "animateClass works with borderStyle", function() {
55
62
var test = $ ( "div.animateClass" ) ,
56
63
count = 0 ;
57
64
expect ( 3 ) ;
58
- test . toggleClass ( "testAddBorder" , 20 , function ( ) {
59
- test . toggleClass ( "testAddBorder" , 20 , function ( ) {
65
+ test . toggleClass ( "testAddBorder" , minDuration , function ( ) {
66
+ test . toggleClass ( "testAddBorder" , minDuration , function ( ) {
60
67
equal ( test . css ( "borderLeftStyle" ) , "none" , "None border set" ) ;
61
68
start ( ) ;
62
69
} ) ;
@@ -69,35 +76,35 @@ asyncTest( "animateClass works with colors", function() {
69
76
var test = $ ( "div.animateClass" ) ,
70
77
count = 0 ;
71
78
expect ( 2 ) ;
72
- test . toggleClass ( "testChangeBackground" , 100 , function ( ) {
79
+ test . toggleClass ( "testChangeBackground" , duration , function ( ) {
73
80
present ( test . css ( "backgroundColor" ) , [ "#ffffff" , "rgb(255, 255, 255)" ] , "Color is final" ) ;
74
81
start ( ) ;
75
82
} ) ;
76
83
setTimeout ( function ( ) {
77
84
var color = test . css ( "backgroundColor" ) ;
78
85
notPresent ( color , [ "#000000" , "#ffffff" , "rgb(0, 0, 0)" , "rgb(255,255,255)" ] ,
79
86
"Color is not endpoints in middle." ) ;
80
- } , 50 ) ;
87
+ } , mid ) ;
81
88
} ) ;
82
89
83
90
asyncTest ( "animateClass works with children" , function ( ) {
84
91
var test = $ ( "div.animateClass" ) ,
85
92
h2 = test . find ( "h2" ) ;
86
-
93
+
87
94
expect ( 4 ) ;
88
- test . toggleClass ( "testChildren" , { children : true , duration : 100 , complete : function ( ) {
95
+ test . toggleClass ( "testChildren" , { children : true , duration : duration , complete : function ( ) {
89
96
equal ( h2 . css ( "fontSize" ) , "20px" , "Text size is final during complete" ) ;
90
- test . toggleClass ( "testChildren" , 100 , function ( ) {
97
+ test . toggleClass ( "testChildren" , duration , function ( ) {
91
98
equal ( h2 . css ( "fontSize" ) , "10px" , "Text size revertted after class removed" ) ;
92
99
start ( ) ;
93
100
} ) ;
94
101
setTimeout ( function ( ) {
95
102
equal ( h2 . css ( "fontSize" ) , "20px" , "Text size unchanged with children: undefined" ) ;
96
- } , 50 ) ;
103
+ } , mid ) ;
97
104
} } ) ;
98
105
setTimeout ( function ( ) {
99
106
notPresent ( h2 . css ( "fontSize" ) , [ "10px" , "20px" ] , "Font size is neither endpoint when in middle." ) ;
100
- } , 50 ) ;
107
+ } , mid ) ;
101
108
} ) ;
102
109
103
110
} ) ( jQuery ) ;
0 commit comments