1
1
( function ( $ ) {
2
2
3
+ function present ( value , array , message ) {
4
+ QUnit . push ( jQuery . inArray ( value , array ) !== - 1 , value , array , message ) ;
5
+ }
6
+
7
+ function notPresent ( value , array , message ) {
8
+ QUnit . push ( jQuery . inArray ( value , array ) === - 1 , value , array , message ) ;
9
+ }
10
+
3
11
var animateTime = 15 ;
4
12
5
13
module ( "effects.core" ) ;
@@ -8,12 +16,10 @@ $.each( $.effects.effect, function( effect ) {
8
16
if ( effect === "transfer" ) {
9
17
return ;
10
18
}
11
- QUnit . reset ( ) ;
12
19
module ( "effect." + effect ) ;
13
- test ( "show/hide" , function ( ) {
20
+ asyncTest ( "show/hide" , function ( ) {
14
21
var hidden = $ ( "div.hidden" ) ;
15
22
expect ( 8 ) ;
16
- stop ( ) ;
17
23
18
24
var count = 0 ,
19
25
test = 0 ;
@@ -23,24 +29,55 @@ $.each( $.effects.effect, function( effect ) {
23
29
var point = count ;
24
30
return function ( next ) {
25
31
test ++ ;
26
- equals ( point , test , "Queue function fired in order" ) ;
32
+ equal ( point , test , "Queue function fired in order" ) ;
27
33
if ( fn ) {
28
- fn ( )
34
+ fn ( ) ;
29
35
} else {
30
36
setTimeout ( next , animateTime ) ;
31
37
}
32
- }
38
+ } ;
33
39
}
34
40
35
41
hidden . queue ( queueTest ( ) ) . show ( effect , animateTime , queueTest ( function ( ) {
36
42
equal ( hidden . css ( "display" ) , "block" , "Hidden is shown after .show(\"" + effect + "\", time)" ) ;
37
43
} ) ) . queue ( queueTest ( ) ) . hide ( effect , animateTime , queueTest ( function ( ) {
38
44
equal ( hidden . css ( "display" ) , "none" , "Back to hidden after .hide(\"" + effect + "\", time)" ) ;
39
45
} ) ) . queue ( queueTest ( function ( next ) {
40
- deepEqual ( hidden . queue ( ) , [ "inprogress" ] , "Only the inprogress sentinel remains" )
46
+ deepEqual ( hidden . queue ( ) , [ "inprogress" ] , "Only the inprogress sentinel remains" ) ;
41
47
start ( ) ;
42
48
} ) ) ;
43
49
} ) ;
44
50
} ) ;
45
51
52
+ module ( "animateClass" ) ;
53
+
54
+ asyncTest ( "animateClass works with borderStyle" , function ( ) {
55
+ var test = $ ( "div.animateClass" ) ,
56
+ count = 0 ;
57
+ expect ( 3 ) ;
58
+ test . toggleClass ( "testAddBorder" , 20 , function ( ) {
59
+ test . toggleClass ( "testAddBorder" , 20 , function ( ) {
60
+ equal ( test . css ( "borderLeftStyle" ) , "none" , "None border set" ) ;
61
+ start ( ) ;
62
+ } ) ;
63
+ equal ( test . css ( "borderLeftStyle" ) , "solid" , "None border not immedately set" ) ;
64
+ } ) ;
65
+ equal ( test . css ( "borderLeftStyle" ) , "solid" , "Solid border immedately set" ) ;
66
+ } ) ;
67
+
68
+ asyncTest ( "animateClass works with colors" , function ( ) {
69
+ var test = $ ( "div.animateClass" ) ,
70
+ count = 0 ;
71
+ expect ( 2 ) ;
72
+ test . toggleClass ( "testChangeBackground" , 100 , function ( ) {
73
+ present ( test . css ( "backgroundColor" ) , [ "#ffffff" , "rgb(255, 255, 255)" ] , "Color is final" ) ;
74
+ start ( ) ;
75
+ } ) ;
76
+ setTimeout ( function ( ) {
77
+ var color = test . css ( "backgroundColor" ) ;
78
+ notPresent ( color , [ "#000000" , "#ffffff" , "rgb(0, 0, 0)" , "rgb(255,255,255)" ] ,
79
+ "Color is not endpoints in middle." ) ;
80
+ } , 50 ) ;
81
+ } ) ;
82
+
46
83
} ) ( jQuery ) ;
0 commit comments