1
1
define ( [
2
+ "qunit" ,
2
3
"jquery" ,
3
4
"./helper" ,
4
5
"ui/widgets/draggable" ,
5
6
"ui/widgets/droppable" ,
6
7
"ui/widgets/resizable"
7
- ] , function ( $ , testHelper ) {
8
+ ] , function ( QUnit , $ , testHelper ) {
8
9
9
- module ( "draggable: core" ) ;
10
+ QUnit . module ( "draggable: core" ) ;
10
11
11
- test ( "element types" , function ( assert ) {
12
+ QUnit . test ( "element types" , function ( assert ) {
12
13
var typeNames = (
13
14
"p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form" +
14
15
",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr" +
15
16
",acronym,code,samp,kbd,var,img,hr" +
16
17
",input,button,label,select,iframe"
17
18
) . split ( "," ) ;
18
19
19
- expect ( typeNames . length * 2 ) ;
20
+ assert . expect ( typeNames . length * 2 ) ;
20
21
21
22
$ . each ( typeNames , function ( i ) {
22
23
var offsetBefore , offsetAfter ,
@@ -44,18 +45,18 @@ test( "element types", function( assert ) {
44
45
} ) ;
45
46
} ) ;
46
47
47
- test ( "No options, relative" , function ( ) {
48
- expect ( 2 ) ;
49
- testHelper . shouldMove ( $ ( "#draggable1" ) . draggable ( ) , "no options, relative" ) ;
48
+ QUnit . test ( "No options, relative" , function ( assert ) {
49
+ assert . expect ( 2 ) ;
50
+ testHelper . shouldMove ( assert , $ ( "#draggable1" ) . draggable ( ) , "no options, relative" ) ;
50
51
} ) ;
51
52
52
- test ( "No options, absolute" , function ( ) {
53
- expect ( 2 ) ;
54
- testHelper . shouldMove ( $ ( "#draggable2" ) . draggable ( ) , "no options, absolute" ) ;
53
+ QUnit . test ( "No options, absolute" , function ( assert ) {
54
+ assert . expect ( 2 ) ;
55
+ testHelper . shouldMove ( assert , $ ( "#draggable2" ) . draggable ( ) , "no options, absolute" ) ;
55
56
} ) ;
56
57
57
- test ( "resizable handle with complex markup (#8756 / #8757)" , function ( ) {
58
- expect ( 2 ) ;
58
+ QUnit . test ( "resizable handle with complex markup (#8756 / #8757)" , function ( assert ) {
59
+ assert . expect ( 2 ) ;
59
60
60
61
$ ( "#draggable1" )
61
62
. append (
@@ -69,34 +70,34 @@ test( "resizable handle with complex markup (#8756 / #8757)", function() {
69
70
70
71
// Todo: fix resizable so it doesn't require a mouseover
71
72
handle . simulate ( "mouseover" ) . simulate ( "drag" , { dx : - 50 } ) ;
72
- equal ( target . width ( ) , 250 , "compare width" ) ;
73
+ assert . equal ( target . width ( ) , 250 , "compare width" ) ;
73
74
74
75
// Todo: fix resizable so it doesn't require a mouseover
75
76
handle . simulate ( "mouseover" ) . simulate ( "drag" , { dx : 50 } ) ;
76
- equal ( target . width ( ) , 200 , "compare width" ) ;
77
+ assert . equal ( target . width ( ) , 200 , "compare width" ) ;
77
78
} ) ;
78
79
79
- test ( "#8269: Removing draggable element on drop" , function ( ) {
80
- expect ( 2 ) ;
80
+ QUnit . test ( "#8269: Removing draggable element on drop" , function ( assert ) {
81
+ assert . expect ( 2 ) ;
81
82
82
83
var element = $ ( "#draggable1" ) . wrap ( "<div id='wrapper' />" ) . draggable ( {
83
84
stop : function ( ) {
84
- ok ( true , "stop still called despite element being removed from DOM on drop" ) ;
85
+ assert . ok ( true , "stop still called despite element being removed from DOM on drop" ) ;
85
86
}
86
87
} ) ,
87
88
dropOffset = $ ( "#droppable" ) . offset ( ) ;
88
89
89
90
$ ( "#droppable" ) . droppable ( {
90
91
drop : function ( ) {
91
92
$ ( "#wrapper" ) . remove ( ) ;
92
- ok ( true , "element removed from DOM on drop" ) ;
93
+ assert . ok ( true , "element removed from DOM on drop" ) ;
93
94
}
94
95
} ) ;
95
96
96
97
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
97
98
if ( testHelper . unreliableContains ) {
98
- ok ( true , "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ) ;
99
- ok ( true , "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ) ;
99
+ assert . ok ( true , "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ) ;
100
+ assert . ok ( true , "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ) ;
100
101
} else {
101
102
element . simulate ( "drag" , {
102
103
handle : "corner" ,
@@ -108,8 +109,8 @@ test( "#8269: Removing draggable element on drop", function() {
108
109
109
110
// http://bugs.jqueryui.com/ticket/7778
110
111
// drag element breaks in IE8 when its content is replaced onmousedown
111
- test ( "Stray mousemove after mousedown still drags" , function ( ) {
112
- expect ( 2 ) ;
112
+ QUnit . test ( "Stray mousemove after mousedown still drags" , function ( assert ) {
113
+ assert . expect ( 2 ) ;
113
114
114
115
var element = $ ( "#draggable1" ) . draggable ( { scroll : false } ) ;
115
116
@@ -120,16 +121,16 @@ test( "Stray mousemove after mousedown still drags", function() {
120
121
$ ( document ) . simulate ( "mousemove" , { button : - 1 } ) ;
121
122
} ) ;
122
123
123
- testHelper . shouldMove ( element , "element is draggable" ) ;
124
+ testHelper . shouldMove ( assert , element , "element is draggable" ) ;
124
125
} ) ;
125
126
126
- test ( "#6258: not following mouse when scrolled and using overflow-y: scroll" , function ( ) {
127
- expect ( 2 ) ;
127
+ QUnit . test ( "#6258: not following mouse when scrolled and using overflow-y: scroll" , function ( assert ) {
128
+ assert . expect ( 2 ) ;
128
129
129
130
var element = $ ( "#draggable1" ) . draggable ( {
130
131
stop : function ( event , ui ) {
131
- equal ( ui . position . left , 1 , "left position is correct despite overflow on HTML" ) ;
132
- equal ( ui . position . top , 1 , "top position is correct despite overflow on HTML" ) ;
132
+ assert . equal ( ui . position . left , 1 , "left position is correct despite overflow on HTML" ) ;
133
+ assert . equal ( ui . position . top , 1 , "top position is correct despite overflow on HTML" ) ;
133
134
$ ( "html" )
134
135
. css ( "overflow-y" , oldOverflowY )
135
136
. css ( "overflow-x" , oldOverflowX )
@@ -155,13 +156,13 @@ test( "#6258: not following mouse when scrolled and using overflow-y: scroll", f
155
156
} ) ;
156
157
} ) ;
157
158
158
- test ( "#9315: jumps down with offset of scrollbar" , function ( ) {
159
- expect ( 2 ) ;
159
+ QUnit . test ( "#9315: jumps down with offset of scrollbar" , function ( assert ) {
160
+ assert . expect ( 2 ) ;
160
161
161
162
var element = $ ( "#draggable2" ) . draggable ( {
162
163
stop : function ( event , ui ) {
163
- equal ( ui . position . left , 11 , "left position is correct when position is absolute" ) ;
164
- equal ( ui . position . top , 11 , "top position is correct when position is absolute" ) ;
164
+ assert . equal ( ui . position . left , 11 , "left position is correct when position is absolute" ) ;
165
+ assert . equal ( ui . position . top , 11 , "top position is correct when position is absolute" ) ;
165
166
$ ( "html" ) . scrollTop ( 0 ) . scrollLeft ( 0 ) ;
166
167
}
167
168
} ) ;
@@ -177,8 +178,8 @@ test( "#9315: jumps down with offset of scrollbar", function() {
177
178
} ) ;
178
179
} ) ;
179
180
180
- test ( "scroll offset with fixed ancestors" , function ( ) {
181
- expect ( 2 ) ;
181
+ QUnit . test ( "scroll offset with fixed ancestors" , function ( assert ) {
182
+ assert . expect ( 2 ) ;
182
183
183
184
var startValue = 300 ,
184
185
element = $ ( "#draggable1" )
@@ -196,8 +197,8 @@ test( "scroll offset with fixed ancestors", function() {
196
197
$ ( document ) . scrollTop ( startValue ) . scrollLeft ( startValue ) ;
197
198
} ,
198
199
stop : function ( event , ui ) {
199
- equal ( ui . position . left , 10 , "left position is correct when parent position is fixed" ) ;
200
- equal ( ui . position . top , 10 , "top position is correct when parent position is fixed" ) ;
200
+ assert . equal ( ui . position . left , 10 , "left position is correct when parent position is fixed" ) ;
201
+ assert . equal ( ui . position . top , 10 , "top position is correct when parent position is fixed" ) ;
201
202
$ ( document ) . scrollTop ( 0 ) . scrollLeft ( 0 ) ;
202
203
}
203
204
} ) ;
@@ -219,8 +220,8 @@ $( [ "hidden", "auto", "scroll" ] ).each( function() {
219
220
220
221
// Http://bugs.jqueryui.com/ticket/9379 - position bug in scrollable div
221
222
// http://bugs.jqueryui.com/ticket/10147 - Wrong position in a parent with "overflow: hidden"
222
- test ( "position in scrollable parent with overflow: " + overflow , function ( ) {
223
- expect ( 2 ) ;
223
+ QUnit . test ( "position in scrollable parent with overflow: " + overflow , function ( assert ) {
224
+ assert . expect ( 2 ) ;
224
225
225
226
$ ( "#qunit-fixture" ) . html ( "<div id='outer'><div id='inner'></div><div id='dragged'>a</div></div>" ) ;
226
227
$ ( "#inner" ) . css ( { position : "absolute" , width : "500px" , height : "500px" } ) ;
@@ -240,8 +241,8 @@ $( [ "hidden", "auto", "scroll" ] ).each( function() {
240
241
$ ( "#outer" ) . scrollTop ( startValue ) . scrollLeft ( startValue ) ;
241
242
} ,
242
243
stop : function ( event , ui ) {
243
- equal ( ui . position . left , expected , "left position is correct when grandparent is scrolled" ) ;
244
- equal ( ui . position . top , expected , "top position is correct when grandparent is scrolled" ) ;
244
+ assert . equal ( ui . position . left , expected , "left position is correct when grandparent is scrolled" ) ;
245
+ assert . equal ( ui . position . top , expected , "top position is correct when grandparent is scrolled" ) ;
245
246
}
246
247
} ) ;
247
248
@@ -255,8 +256,8 @@ $( [ "hidden", "auto", "scroll" ] ).each( function() {
255
256
} ) ;
256
257
} ) ;
257
258
258
- test ( "#5727: draggable from iframe" , function ( ) {
259
- expect ( 1 ) ;
259
+ QUnit . test ( "#5727: draggable from iframe" , function ( assert ) {
260
+ assert . expect ( 1 ) ;
260
261
261
262
var iframeBody , draggable1 ,
262
263
iframe = $ ( "<iframe />" ) . appendTo ( "#qunit-fixture" ) ,
@@ -270,53 +271,55 @@ test( "#5727: draggable from iframe", function() {
270
271
271
272
draggable1 . draggable ( ) ;
272
273
273
- equal ( draggable1 . closest ( iframeBody ) . length , 1 ) ;
274
+ assert . equal ( draggable1 . closest ( iframeBody ) . length , 1 ) ;
274
275
275
276
// TODO: fix draggable within an IFRAME to fire events on the element properly
276
277
// and these testHelper.shouldMove relies on events for testing
277
- //testHelper.shouldMove( draggable1, "draggable from an iframe" );
278
+ //testHelper.shouldMove( assert, draggable1, "draggable from an iframe" );
278
279
} ) ;
279
280
280
- test ( "#8399: A draggable should become the active element after you are finished interacting with it, but not before." , function ( ) {
281
- expect ( 2 ) ;
281
+ QUnit . test ( "#8399: A draggable should become the active element after you are finished interacting with it, but not before." , function ( assert ) {
282
+ assert . expect ( 2 ) ;
282
283
283
284
var element = $ ( "<a href='#'>link</a>" ) . appendTo ( "#qunit-fixture" ) . draggable ( ) ;
284
285
285
286
$ ( document ) . one ( "mousemove" , function ( ) {
286
- notStrictEqual ( document . activeElement , element . get ( 0 ) , "moving a draggable anchor did not make it the active element" ) ;
287
+ assert . notStrictEqual ( document . activeElement , element . get ( 0 ) , "moving a draggable anchor did not make it the active element" ) ;
287
288
} ) ;
288
289
289
290
testHelper . move ( element , 50 , 50 ) ;
290
291
291
- strictEqual ( document . activeElement , element . get ( 0 ) , "finishing moving a draggable anchor made it the active element" ) ;
292
+ assert . strictEqual ( document . activeElement , element . get ( 0 ) , "finishing moving a draggable anchor made it the active element" ) ;
292
293
} ) ;
293
294
294
- asyncTest ( "blur behavior - handle is main element" , function ( ) {
295
- expect ( 3 ) ;
295
+ QUnit . test ( "blur behavior - handle is main element" , function ( assert ) {
296
+ var ready = assert . async ( ) ;
297
+ assert . expect ( 3 ) ;
296
298
297
299
var element = $ ( "#draggable1" ) . draggable ( ) ,
298
300
focusElement = $ ( "<div tabindex='1'></div>" ) . appendTo ( element ) ;
299
301
300
302
testHelper . onFocus ( focusElement , function ( ) {
301
- strictEqual ( document . activeElement , focusElement . get ( 0 ) , "test element is focused before mousing down on a draggable" ) ;
303
+ assert . strictEqual ( document . activeElement , focusElement . get ( 0 ) , "test element is focused before mousing down on a draggable" ) ;
302
304
303
305
testHelper . move ( focusElement , 1 , 1 ) ;
304
306
305
307
// Http://bugs.jqueryui.com/ticket/10527
306
308
// Draggable: Can't select option in modal dialog (IE8)
307
- strictEqual ( document . activeElement , focusElement . get ( 0 ) , "test element is focused after mousing down on itself" ) ;
309
+ assert . strictEqual ( document . activeElement , focusElement . get ( 0 ) , "test element is focused after mousing down on itself" ) ;
308
310
309
311
testHelper . move ( element , 50 , 50 ) ;
310
312
311
313
// Http://bugs.jqueryui.com/ticket/4261
312
314
// active element should blur when mousing down on a draggable
313
- notStrictEqual ( document . activeElement , focusElement . get ( 0 ) , "test element is no longer focused after mousing down on a draggable" ) ;
314
- start ( ) ;
315
+ assert . notStrictEqual ( document . activeElement , focusElement . get ( 0 ) , "test element is no longer focused after mousing down on a draggable" ) ;
316
+ ready ( ) ;
315
317
} ) ;
316
318
} ) ;
317
319
318
- asyncTest ( "blur behavior - descendant of handle" , function ( ) {
319
- expect ( 2 ) ;
320
+ QUnit . test ( "blur behavior - descendant of handle" , function ( assert ) {
321
+ var ready = assert . async ( ) ;
322
+ assert . expect ( 2 ) ;
320
323
321
324
var element = $ ( "#draggable2" ) . draggable ( { handle : "span" } ) ,
322
325
@@ -325,18 +328,18 @@ asyncTest( "blur behavior - descendant of handle", function() {
325
328
focusElement = $ ( "<div tabindex='1'></div>" ) . appendTo ( element ) ;
326
329
327
330
testHelper . onFocus ( focusElement , function ( ) {
328
- strictEqual ( document . activeElement , focusElement . get ( 0 ) , "test element is focused before mousing down on a draggable" ) ;
331
+ assert . strictEqual ( document . activeElement , focusElement . get ( 0 ) , "test element is focused before mousing down on a draggable" ) ;
329
332
330
333
testHelper . move ( handle , 50 , 50 ) ;
331
334
332
335
// Elements outside of the handle should blur (#12472, #14905)
333
- notStrictEqual ( document . activeElement , focusElement . get ( 0 ) , "test element is no longer focused after mousing down on a draggable" ) ;
334
- start ( ) ;
336
+ assert . notStrictEqual ( document . activeElement , focusElement . get ( 0 ) , "test element is no longer focused after mousing down on a draggable" ) ;
337
+ ready ( ) ;
335
338
} ) ;
336
339
} ) ;
337
340
338
- test ( "ui-draggable-handle assigned to appropriate element" , function ( assert ) {
339
- expect ( 5 ) ;
341
+ QUnit . test ( "ui-draggable-handle assigned to appropriate element" , function ( assert ) {
342
+ assert . expect ( 5 ) ;
340
343
341
344
var p = $ ( "<p>" ) . appendTo ( "#qunit-fixture" ) ,
342
345
element = $ ( "<div><p></p></div>" ) . appendTo ( "#qunit-fixture" ) . draggable ( ) ;
@@ -352,8 +355,8 @@ test( "ui-draggable-handle assigned to appropriate element", function( assert )
352
355
assert . lacksClasses ( element . find ( "p" ) , "ui-draggable-handle" ) ;
353
356
} ) ;
354
357
355
- test ( "ui-draggable-handle managed correctly in nested draggables" , function ( assert ) {
356
- expect ( 4 ) ;
358
+ QUnit . test ( "ui-draggable-handle managed correctly in nested draggables" , function ( assert ) {
359
+ assert . expect ( 4 ) ;
357
360
var parent = $ ( "<div><div></div></div>" ) . draggable ( ) . appendTo ( "#qunit-fixture" ) ,
358
361
child = parent . find ( "div" ) . draggable ( ) ;
359
362
@@ -371,7 +374,7 @@ test( "ui-draggable-handle managed correctly in nested draggables", function( as
371
374
QUnit [ document . documentMode === 8 ? "skip" : "test" ] (
372
375
"does not stop propagation to window" ,
373
376
function ( assert ) {
374
- expect ( 1 ) ;
377
+ assert . expect ( 1 ) ;
375
378
var element = $ ( "#draggable1" ) . draggable ( ) ;
376
379
377
380
var handler = function ( ) {
0 commit comments