1
1
define ( [
2
+ "qunit" ,
2
3
"jquery" ,
3
4
"ui/widget"
4
- ] , function ( $ ) {
5
+ ] , function ( QUnit , $ ) {
5
6
6
- module ( "widget animation" , ( function ( ) {
7
+ QUnit . module ( "widget animation" , ( function ( ) {
7
8
var show = $ . fn . show ,
8
9
fadeIn = $ . fn . fadeIn ,
9
10
slideDown = $ . fn . slideDown ;
10
11
return {
11
- setup : function ( ) {
12
+ beforeEach : function ( ) {
12
13
$ . widget ( "ui.testWidget" , {
13
14
_create : function ( ) {
14
15
this . element . hide ( ) ;
@@ -19,7 +20,7 @@ module( "widget animation", ( function() {
19
20
} ) ;
20
21
$ . effects = { effect : { testEffect : $ . noop } } ;
21
22
} ,
22
- teardown : function ( ) {
23
+ afterEach : function ( ) {
23
24
delete $ . ui . testWidget ;
24
25
delete $ . effects . effect . testEffect ;
25
26
$ . fn . show = show ;
@@ -29,43 +30,45 @@ module( "widget animation", ( function() {
29
30
} ;
30
31
} ( ) ) ) ;
31
32
32
- asyncTest ( "show: null" , function ( ) {
33
- expect ( 4 ) ;
33
+ QUnit . test ( "show: null" , function ( assert ) {
34
+ var ready = assert . async ( ) ;
35
+ assert . expect ( 4 ) ;
34
36
35
37
var element = $ ( "#widget" ) . testWidget ( ) ,
36
38
hasRun = false ;
37
39
$ . fn . show = function ( ) {
38
- ok ( true , "show called" ) ;
39
- equal ( arguments . length , 0 , "no args passed to show" ) ;
40
+ assert . ok ( true , "show called" ) ;
41
+ assert . equal ( arguments . length , 0 , "no args passed to show" ) ;
40
42
} ;
41
43
42
44
element
43
45
. delay ( 50 )
44
46
. queue ( function ( next ) {
45
- ok ( ! hasRun , "queue before show" ) ;
47
+ assert . ok ( ! hasRun , "queue before show" ) ;
46
48
next ( ) ;
47
49
} )
48
50
. testWidget ( "show" , function ( ) {
49
51
hasRun = true ;
50
52
} )
51
53
. queue ( function ( next ) {
52
- ok ( hasRun , "queue after show" ) ;
53
- start ( ) ;
54
+ assert . ok ( hasRun , "queue after show" ) ;
55
+ ready ( ) ;
54
56
next ( ) ;
55
57
} ) ;
56
58
} ) ;
57
59
58
- asyncTest ( "show: true" , function ( ) {
59
- expect ( 4 ) ;
60
+ QUnit . test ( "show: true" , function ( assert ) {
61
+ var ready = assert . async ( ) ;
62
+ assert . expect ( 4 ) ;
60
63
61
64
var element = $ ( "#widget" ) . testWidget ( {
62
65
show : true
63
66
} ) ,
64
67
hasRun = false ;
65
68
$ . fn . fadeIn = function ( duration , easing , complete ) {
66
69
return this . queue ( function ( next ) {
67
- strictEqual ( duration , undefined , "duration" ) ;
68
- strictEqual ( easing , undefined , "easing" ) ;
70
+ assert . strictEqual ( duration , undefined , "duration" ) ;
71
+ assert . strictEqual ( easing , undefined , "easing" ) ;
69
72
complete ( ) ;
70
73
next ( ) ;
71
74
} ) ;
@@ -74,30 +77,31 @@ asyncTest( "show: true", function() {
74
77
element
75
78
. delay ( 50 )
76
79
. queue ( function ( next ) {
77
- ok ( ! hasRun , "queue before show" ) ;
80
+ assert . ok ( ! hasRun , "queue before show" ) ;
78
81
next ( ) ;
79
82
} )
80
83
. testWidget ( "show" , function ( ) {
81
84
hasRun = true ;
82
85
} )
83
86
. queue ( function ( next ) {
84
- ok ( hasRun , "queue after show" ) ;
85
- start ( ) ;
87
+ assert . ok ( hasRun , "queue after show" ) ;
88
+ ready ( ) ;
86
89
next ( ) ;
87
90
} ) ;
88
91
} ) ;
89
92
90
- asyncTest ( "show: number" , function ( ) {
91
- expect ( 4 ) ;
93
+ QUnit . test ( "show: number" , function ( assert ) {
94
+ var ready = assert . async ( ) ;
95
+ assert . expect ( 4 ) ;
92
96
93
97
var element = $ ( "#widget" ) . testWidget ( {
94
98
show : 123
95
99
} ) ,
96
100
hasRun = false ;
97
101
$ . fn . fadeIn = function ( duration , easing , complete ) {
98
102
return this . queue ( function ( next ) {
99
- strictEqual ( duration , 123 , "duration" ) ;
100
- strictEqual ( easing , undefined , "easing" ) ;
103
+ assert . strictEqual ( duration , 123 , "duration" ) ;
104
+ assert . strictEqual ( easing , undefined , "easing" ) ;
101
105
complete ( ) ;
102
106
next ( ) ;
103
107
} ) ;
@@ -106,30 +110,31 @@ asyncTest( "show: number", function() {
106
110
element
107
111
. delay ( 50 )
108
112
. queue ( function ( next ) {
109
- ok ( ! hasRun , "queue before show" ) ;
113
+ assert . ok ( ! hasRun , "queue before show" ) ;
110
114
next ( ) ;
111
115
} )
112
116
. testWidget ( "show" , function ( ) {
113
117
hasRun = true ;
114
118
} )
115
119
. queue ( function ( next ) {
116
- ok ( hasRun , "queue after show" ) ;
117
- start ( ) ;
120
+ assert . ok ( hasRun , "queue after show" ) ;
121
+ ready ( ) ;
118
122
next ( ) ;
119
123
} ) ;
120
124
} ) ;
121
125
122
- asyncTest ( "show: core animation" , function ( ) {
123
- expect ( 4 ) ;
126
+ QUnit . test ( "show: core animation" , function ( assert ) {
127
+ var ready = assert . async ( ) ;
128
+ assert . expect ( 4 ) ;
124
129
125
130
var element = $ ( "#widget" ) . testWidget ( {
126
131
show : "slideDown"
127
132
} ) ,
128
133
hasRun = false ;
129
134
$ . fn . slideDown = function ( duration , easing , complete ) {
130
135
return this . queue ( function ( next ) {
131
- strictEqual ( duration , undefined , "duration" ) ;
132
- strictEqual ( easing , undefined , "easing" ) ;
136
+ assert . strictEqual ( duration , undefined , "duration" ) ;
137
+ assert . strictEqual ( easing , undefined , "easing" ) ;
133
138
complete ( ) ;
134
139
next ( ) ;
135
140
} ) ;
@@ -138,31 +143,32 @@ asyncTest( "show: core animation", function() {
138
143
element
139
144
. delay ( 50 )
140
145
. queue ( function ( next ) {
141
- ok ( ! hasRun , "queue before show" ) ;
146
+ assert . ok ( ! hasRun , "queue before show" ) ;
142
147
next ( ) ;
143
148
} )
144
149
. testWidget ( "show" , function ( ) {
145
150
hasRun = true ;
146
151
} )
147
152
. queue ( function ( next ) {
148
- ok ( hasRun , "queue after show" ) ;
149
- start ( ) ;
153
+ assert . ok ( hasRun , "queue after show" ) ;
154
+ ready ( ) ;
150
155
next ( ) ;
151
156
} ) ;
152
157
} ) ;
153
158
154
- asyncTest ( "show: effect" , function ( ) {
155
- expect ( 5 ) ;
159
+ QUnit . test ( "show: effect" , function ( assert ) {
160
+ var ready = assert . async ( ) ;
161
+ assert . expect ( 5 ) ;
156
162
157
163
var element = $ ( "#widget" ) . testWidget ( {
158
164
show : "testEffect"
159
165
} ) ,
160
166
hasRun = false ;
161
167
$ . fn . show = function ( options ) {
162
168
return this . queue ( function ( next ) {
163
- equal ( options . effect , "testEffect" , "effect" ) ;
164
- ok ( ! ( "duration" in options ) , "duration" ) ;
165
- ok ( ! ( "easing" in options ) , "easing" ) ;
169
+ assert . equal ( options . effect , "testEffect" , "effect" ) ;
170
+ assert . ok ( ! ( "duration" in options ) , "duration" ) ;
171
+ assert . ok ( ! ( "easing" in options ) , "easing" ) ;
166
172
options . complete ( ) ;
167
173
next ( ) ;
168
174
} ) ;
@@ -171,21 +177,22 @@ asyncTest( "show: effect", function() {
171
177
element
172
178
. delay ( 50 )
173
179
. queue ( function ( next ) {
174
- ok ( ! hasRun , "queue before show" ) ;
180
+ assert . ok ( ! hasRun , "queue before show" ) ;
175
181
next ( ) ;
176
182
} )
177
183
. testWidget ( "show" , function ( ) {
178
184
hasRun = true ;
179
185
} )
180
186
. queue ( function ( next ) {
181
- ok ( hasRun , "queue after show" ) ;
182
- start ( ) ;
187
+ assert . ok ( hasRun , "queue after show" ) ;
188
+ ready ( ) ;
183
189
next ( ) ;
184
190
} ) ;
185
191
} ) ;
186
192
187
- asyncTest ( "show: object(core animation)" , function ( ) {
188
- expect ( 4 ) ;
193
+ QUnit . test ( "show: object(core animation)" , function ( assert ) {
194
+ var ready = assert . async ( ) ;
195
+ assert . expect ( 4 ) ;
189
196
190
197
var element = $ ( "#widget" ) . testWidget ( {
191
198
show : {
@@ -197,8 +204,8 @@ asyncTest( "show: object(core animation)", function() {
197
204
hasRun = false ;
198
205
$ . fn . slideDown = function ( duration , easing , complete ) {
199
206
return this . queue ( function ( next ) {
200
- equal ( duration , 123 , "duration" ) ;
201
- equal ( easing , "testEasing" , "easing" ) ;
207
+ assert . equal ( duration , 123 , "duration" ) ;
208
+ assert . equal ( easing , "testEasing" , "easing" ) ;
202
209
complete ( ) ;
203
210
next ( ) ;
204
211
} ) ;
@@ -207,21 +214,22 @@ asyncTest( "show: object(core animation)", function() {
207
214
element
208
215
. delay ( 50 )
209
216
. queue ( function ( next ) {
210
- ok ( ! hasRun , "queue before show" ) ;
217
+ assert . ok ( ! hasRun , "queue before show" ) ;
211
218
next ( ) ;
212
219
} )
213
220
. testWidget ( "show" , function ( ) {
214
221
hasRun = true ;
215
222
} )
216
223
. queue ( function ( next ) {
217
- ok ( hasRun , "queue after show" ) ;
218
- start ( ) ;
224
+ assert . ok ( hasRun , "queue after show" ) ;
225
+ ready ( ) ;
219
226
next ( ) ;
220
227
} ) ;
221
228
} ) ;
222
229
223
- asyncTest ( "show: object(effect)" , function ( ) {
224
- expect ( 3 ) ;
230
+ QUnit . test ( "show: object(effect)" , function ( assert ) {
231
+ var ready = assert . async ( ) ;
232
+ assert . expect ( 3 ) ;
225
233
226
234
var element = $ ( "#widget" ) . testWidget ( {
227
235
show : {
@@ -233,7 +241,7 @@ asyncTest( "show: object(effect)", function() {
233
241
hasRun = false ;
234
242
$ . fn . show = function ( options ) {
235
243
return this . queue ( function ( next ) {
236
- deepEqual ( options , {
244
+ assert . deepEqual ( options , {
237
245
effect : "testEffect" ,
238
246
duration : 123 ,
239
247
easing : "testEasing" ,
@@ -247,15 +255,15 @@ asyncTest( "show: object(effect)", function() {
247
255
element
248
256
. delay ( 50 )
249
257
. queue ( function ( next ) {
250
- ok ( ! hasRun , "queue before show" ) ;
258
+ assert . ok ( ! hasRun , "queue before show" ) ;
251
259
next ( ) ;
252
260
} )
253
261
. testWidget ( "show" , function ( ) {
254
262
hasRun = true ;
255
263
} )
256
264
. queue ( function ( next ) {
257
- ok ( hasRun , "queue after show" ) ;
258
- start ( ) ;
265
+ assert . ok ( hasRun , "queue after show" ) ;
266
+ ready ( ) ;
259
267
next ( ) ;
260
268
} ) ;
261
269
} ) ;
0 commit comments