define( [
+ "qunit",
"jquery",
"./helper",
"ui/widgets/draggable",
"ui/widgets/droppable",
"ui/widgets/resizable"
-], function( $, testHelper ) {
+], function( QUnit, $, testHelper ) {
-module( "draggable: core" );
+QUnit.module( "draggable: core" );
-test( "element types", function( assert ) {
+QUnit.test( "element types", function( assert ) {
var typeNames = (
"p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form" +
",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr" +
",input,button,label,select,iframe"
).split( "," );
- expect( typeNames.length * 2 );
+ assert.expect( typeNames.length * 2 );
$.each( typeNames, function( i ) {
var offsetBefore, offsetAfter,
} );
} );
-test( "No options, relative", function() {
- expect( 2 );
- testHelper.shouldMove( $( "#draggable1" ).draggable(), "no options, relative" );
+QUnit.test( "No options, relative", function( assert ) {
+ assert.expect( 2 );
+ testHelper.shouldMove( assert, $( "#draggable1" ).draggable(), "no options, relative" );
} );
-test( "No options, absolute", function() {
- expect( 2 );
- testHelper.shouldMove( $( "#draggable2" ).draggable(), "no options, absolute" );
+QUnit.test( "No options, absolute", function( assert ) {
+ assert.expect( 2 );
+ testHelper.shouldMove( assert, $( "#draggable2" ).draggable(), "no options, absolute" );
} );
-test( "resizable handle with complex markup (#8756 / #8757)", function() {
- expect( 2 );
+QUnit.test( "resizable handle with complex markup (#8756 / #8757)", function( assert ) {
+ assert.expect( 2 );
$( "#draggable1" )
.append(
// Todo: fix resizable so it doesn't require a mouseover
handle.simulate( "mouseover" ).simulate( "drag", { dx: -50 } );
- equal( target.width(), 250, "compare width" );
+ assert.equal( target.width(), 250, "compare width" );
// Todo: fix resizable so it doesn't require a mouseover
handle.simulate( "mouseover" ).simulate( "drag", { dx: 50 } );
- equal( target.width(), 200, "compare width" );
+ assert.equal( target.width(), 200, "compare width" );
} );
-test( "#8269: Removing draggable element on drop", function() {
- expect( 2 );
+QUnit.test( "#8269: Removing draggable element on drop", function( assert ) {
+ assert.expect( 2 );
var element = $( "#draggable1" ).wrap( "<div id='wrapper' />" ).draggable( {
stop: function() {
- ok( true, "stop still called despite element being removed from DOM on drop" );
+ assert.ok( true, "stop still called despite element being removed from DOM on drop" );
}
} ),
dropOffset = $( "#droppable" ).offset();
$( "#droppable" ).droppable( {
drop: function() {
$( "#wrapper" ).remove();
- ok( true, "element removed from DOM on drop" );
+ assert.ok( true, "element removed from DOM on drop" );
}
} );
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
if ( testHelper.unreliableContains ) {
- ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
- ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
+ assert.ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
+ assert.ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
} else {
element.simulate( "drag", {
handle: "corner",
// http://bugs.jqueryui.com/ticket/7778
// drag element breaks in IE8 when its content is replaced onmousedown
-test( "Stray mousemove after mousedown still drags", function() {
- expect( 2 );
+QUnit.test( "Stray mousemove after mousedown still drags", function( assert ) {
+ assert.expect( 2 );
var element = $( "#draggable1" ).draggable( { scroll: false } );
$( document ).simulate( "mousemove", { button: -1 } );
} );
- testHelper.shouldMove( element, "element is draggable" );
+ testHelper.shouldMove( assert, element, "element is draggable" );
} );
-test( "#6258: not following mouse when scrolled and using overflow-y: scroll", function() {
- expect( 2 );
+QUnit.test( "#6258: not following mouse when scrolled and using overflow-y: scroll", function( assert ) {
+ assert.expect( 2 );
var element = $( "#draggable1" ).draggable( {
stop: function( event, ui ) {
- equal( ui.position.left, 1, "left position is correct despite overflow on HTML" );
- equal( ui.position.top, 1, "top position is correct despite overflow on HTML" );
+ assert.equal( ui.position.left, 1, "left position is correct despite overflow on HTML" );
+ assert.equal( ui.position.top, 1, "top position is correct despite overflow on HTML" );
$( "html" )
.css( "overflow-y", oldOverflowY )
.css( "overflow-x", oldOverflowX )
} );
} );
-test( "#9315: jumps down with offset of scrollbar", function() {
- expect( 2 );
+QUnit.test( "#9315: jumps down with offset of scrollbar", function( assert ) {
+ assert.expect( 2 );
var element = $( "#draggable2" ).draggable( {
stop: function( event, ui ) {
- equal( ui.position.left, 11, "left position is correct when position is absolute" );
- equal( ui.position.top, 11, "top position is correct when position is absolute" );
+ assert.equal( ui.position.left, 11, "left position is correct when position is absolute" );
+ assert.equal( ui.position.top, 11, "top position is correct when position is absolute" );
$( "html" ).scrollTop( 0 ).scrollLeft( 0 );
}
} );
} );
} );
-test( "scroll offset with fixed ancestors", function() {
- expect( 2 );
+QUnit.test( "scroll offset with fixed ancestors", function( assert ) {
+ assert.expect( 2 );
var startValue = 300,
element = $( "#draggable1" )
$( document ).scrollTop( startValue ).scrollLeft( startValue );
},
stop: function( event, ui ) {
- equal( ui.position.left, 10, "left position is correct when parent position is fixed" );
- equal( ui.position.top, 10, "top position is correct when parent position is fixed" );
+ assert.equal( ui.position.left, 10, "left position is correct when parent position is fixed" );
+ assert.equal( ui.position.top, 10, "top position is correct when parent position is fixed" );
$( document ).scrollTop( 0 ).scrollLeft( 0 );
}
} );
// Http://bugs.jqueryui.com/ticket/9379 - position bug in scrollable div
// http://bugs.jqueryui.com/ticket/10147 - Wrong position in a parent with "overflow: hidden"
- test( "position in scrollable parent with overflow: " + overflow, function() {
- expect( 2 );
+ QUnit.test( "position in scrollable parent with overflow: " + overflow, function( assert ) {
+ assert.expect( 2 );
$( "#qunit-fixture" ).html( "<div id='outer'><div id='inner'></div><div id='dragged'>a</div></div>" );
$( "#inner" ).css( { position: "absolute", width: "500px", height: "500px" } );
$( "#outer" ).scrollTop( startValue ).scrollLeft( startValue );
},
stop: function( event, ui ) {
- equal( ui.position.left, expected, "left position is correct when grandparent is scrolled" );
- equal( ui.position.top, expected, "top position is correct when grandparent is scrolled" );
+ assert.equal( ui.position.left, expected, "left position is correct when grandparent is scrolled" );
+ assert.equal( ui.position.top, expected, "top position is correct when grandparent is scrolled" );
}
} );
} );
} );
-test( "#5727: draggable from iframe", function() {
- expect( 1 );
+QUnit.test( "#5727: draggable from iframe", function( assert ) {
+ assert.expect( 1 );
var iframeBody, draggable1,
iframe = $( "<iframe />" ).appendTo( "#qunit-fixture" ),
draggable1.draggable();
- equal( draggable1.closest( iframeBody ).length, 1 );
+ assert.equal( draggable1.closest( iframeBody ).length, 1 );
// TODO: fix draggable within an IFRAME to fire events on the element properly
// and these testHelper.shouldMove relies on events for testing
- //testHelper.shouldMove( draggable1, "draggable from an iframe" );
+ //testHelper.shouldMove( assert, draggable1, "draggable from an iframe" );
} );
-test( "#8399: A draggable should become the active element after you are finished interacting with it, but not before.", function() {
- expect( 2 );
+QUnit.test( "#8399: A draggable should become the active element after you are finished interacting with it, but not before.", function( assert ) {
+ assert.expect( 2 );
var element = $( "<a href='#'>link</a>" ).appendTo( "#qunit-fixture" ).draggable();
$( document ).one( "mousemove", function() {
- notStrictEqual( document.activeElement, element.get( 0 ), "moving a draggable anchor did not make it the active element" );
+ assert.notStrictEqual( document.activeElement, element.get( 0 ), "moving a draggable anchor did not make it the active element" );
} );
testHelper.move( element, 50, 50 );
- strictEqual( document.activeElement, element.get( 0 ), "finishing moving a draggable anchor made it the active element" );
+ assert.strictEqual( document.activeElement, element.get( 0 ), "finishing moving a draggable anchor made it the active element" );
} );
-asyncTest( "blur behavior - handle is main element", function() {
- expect( 3 );
+QUnit.test( "blur behavior - handle is main element", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 3 );
var element = $( "#draggable1" ).draggable(),
focusElement = $( "<div tabindex='1'></div>" ).appendTo( element );
testHelper.onFocus( focusElement, function() {
- strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused before mousing down on a draggable" );
+ assert.strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused before mousing down on a draggable" );
testHelper.move( focusElement, 1, 1 );
// Http://bugs.jqueryui.com/ticket/10527
// Draggable: Can't select option in modal dialog (IE8)
- strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused after mousing down on itself" );
+ assert.strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused after mousing down on itself" );
testHelper.move( element, 50, 50 );
// Http://bugs.jqueryui.com/ticket/4261
// active element should blur when mousing down on a draggable
- notStrictEqual( document.activeElement, focusElement.get( 0 ), "test element is no longer focused after mousing down on a draggable" );
- start();
+ assert.notStrictEqual( document.activeElement, focusElement.get( 0 ), "test element is no longer focused after mousing down on a draggable" );
+ ready();
} );
} );
-asyncTest( "blur behavior - descendant of handle", function() {
- expect( 2 );
+QUnit.test( "blur behavior - descendant of handle", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 2 );
var element = $( "#draggable2" ).draggable( { handle: "span" } ),
focusElement = $( "<div tabindex='1'></div>" ).appendTo( element );
testHelper.onFocus( focusElement, function() {
- strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused before mousing down on a draggable" );
+ assert.strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused before mousing down on a draggable" );
testHelper.move( handle, 50, 50 );
// Elements outside of the handle should blur (#12472, #14905)
- notStrictEqual( document.activeElement, focusElement.get( 0 ), "test element is no longer focused after mousing down on a draggable" );
- start();
+ assert.notStrictEqual( document.activeElement, focusElement.get( 0 ), "test element is no longer focused after mousing down on a draggable" );
+ ready();
} );
} );
-test( "ui-draggable-handle assigned to appropriate element", function( assert ) {
- expect( 5 );
+QUnit.test( "ui-draggable-handle assigned to appropriate element", function( assert ) {
+ assert.expect( 5 );
var p = $( "<p>" ).appendTo( "#qunit-fixture" ),
element = $( "<div><p></p></div>" ).appendTo( "#qunit-fixture" ).draggable();
assert.lacksClasses( element.find( "p" ), "ui-draggable-handle" );
} );
-test( "ui-draggable-handle managed correctly in nested draggables", function( assert ) {
- expect( 4 );
+QUnit.test( "ui-draggable-handle managed correctly in nested draggables", function( assert ) {
+ assert.expect( 4 );
var parent = $( "<div><div></div></div>" ).draggable().appendTo( "#qunit-fixture" ),
child = parent.find( "div" ).draggable();
QUnit[ document.documentMode === 8 ? "skip" : "test" ](
"does not stop propagation to window",
function( assert ) {
- expect( 1 );
+ assert.expect( 1 );
var element = $( "#draggable1" ).draggable();
var handler = function() {
define( [
+ "qunit",
"jquery",
"./helper",
"ui/widgets/draggable",
"ui/widgets/droppable",
"ui/widgets/sortable"
-], function( $, testHelper ) {
+], function( QUnit, $, testHelper ) {
-module( "draggable: options" );
+QUnit.module( "draggable: options" );
// TODO: This doesn't actually test whether append happened, possibly remove
-test( "{ appendTo: 'parent' }, default, no clone", function() {
- expect( 4 );
+QUnit.test( "{ appendTo: 'parent' }, default, no clone", function( assert ) {
+ assert.expect( 4 );
var element = $( "#draggable2" ).draggable( { appendTo: "parent" } );
- testHelper.shouldMove( element, "absolute appendTo: parent" );
+ testHelper.shouldMove( assert, element, "absolute appendTo: parent" );
element = $( "#draggable1" ).draggable( { appendTo: "parent" } );
- testHelper.shouldMove( element, "relative appendTo: parent" );
+ testHelper.shouldMove( assert, element, "relative appendTo: parent" );
} );
// TODO: This doesn't actually test whether append happened, possibly remove
-test( "{ appendTo: Element }, no clone", function() {
- expect( 4 );
+QUnit.test( "{ appendTo: Element }, no clone", function( assert ) {
+ assert.expect( 4 );
var element = $( "#draggable2" ).draggable( { appendTo: $( "#draggable2" ).parent()[ 0 ] } );
- testHelper.shouldMove( element, "absolute appendTo: Element" );
+ testHelper.shouldMove( assert, element, "absolute appendTo: Element" );
element = $( "#draggable1" ).draggable( { appendTo: $( "#draggable2" ).parent()[ 0 ] } );
- testHelper.shouldMove( element, "relative appendTo: Element" );
+ testHelper.shouldMove( assert, element, "relative appendTo: Element" );
} );
// TODO: This doesn't actually test whether append happened, possibly remove
-test( "{ appendTo: Selector }, no clone", function() {
- expect( 4 );
+QUnit.test( "{ appendTo: Selector }, no clone", function( assert ) {
+ assert.expect( 4 );
var element = $( "#draggable2" ).draggable( { appendTo: "#main" } );
- testHelper.shouldMove( element, "absolute appendTo: Selector" );
+ testHelper.shouldMove( assert, element, "absolute appendTo: Selector" );
element = $( "#draggable1" ).draggable( { appendTo: "#main" } );
- testHelper.shouldMove( element, "relative appendTo: Selector" );
+ testHelper.shouldMove( assert, element, "relative appendTo: Selector" );
} );
-test( "{ appendTo: 'parent' }, default", function() {
- expect( 2 );
+QUnit.test( "{ appendTo: 'parent' }, default", function( assert ) {
+ assert.expect( 2 );
var element = $( "#draggable1" ).draggable();
testHelper.trackAppendedParent( element );
- equal( element.draggable( "option", "appendTo" ), "parent" );
+ assert.equal( element.draggable( "option", "appendTo" ), "parent" );
testHelper.move( element, 1, 1 );
- equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
+ assert.equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
} );
-test( "{ appendTo: Element }", function() {
- expect( 1 );
+QUnit.test( "{ appendTo: Element }", function( assert ) {
+ assert.expect( 1 );
var appendTo = $( "#draggable2" ).parent()[ 0 ],
element = $( "#draggable1" ).draggable( { appendTo: appendTo } );
testHelper.trackAppendedParent( element );
testHelper.move( element, 1, 1 );
- equal( element.data( "last_dragged_parent" ), appendTo );
+ assert.equal( element.data( "last_dragged_parent" ), appendTo );
} );
-test( "{ appendTo: jQuery }", function() {
- expect( 1 );
+QUnit.test( "{ appendTo: jQuery }", function( assert ) {
+ assert.expect( 1 );
var appendTo = $( "#draggable2" ).parent(),
element = $( "#draggable1" ).draggable( { appendTo: appendTo } );
testHelper.trackAppendedParent( element );
testHelper.move( element, 1, 1 );
- equal( element.data( "last_dragged_parent" ), appendTo[ 0 ] );
+ assert.equal( element.data( "last_dragged_parent" ), appendTo[ 0 ] );
} );
-test( "{ appendTo: Selector }", function() {
- expect( 1 );
+QUnit.test( "{ appendTo: Selector }", function( assert ) {
+ assert.expect( 1 );
var appendTo = "#main",
element = $( "#draggable1" ).draggable( { appendTo: appendTo } );
testHelper.trackAppendedParent( element );
testHelper.move( element, 1, 1 );
- equal( element.data( "last_dragged_parent" ), $( appendTo )[ 0 ] );
+ assert.equal( element.data( "last_dragged_parent" ), $( appendTo )[ 0 ] );
} );
-test( "appendTo, default, switching after initialization", function() {
- expect( 2 );
+QUnit.test( "appendTo, default, switching after initialization", function( assert ) {
+ assert.expect( 2 );
var element = $( "#draggable1" ).draggable( { helper: "clone" } );
// Move and make sure element was appended to fixture
testHelper.move( element, 1, 1 );
- equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
+ assert.equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
// Move and make sure element was appended to main
element.draggable( "option", "appendTo", $( "#qunit-fixture" ) );
testHelper.move( element, 2, 2 );
- equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] );
+ assert.equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] );
} );
-test( "{ axis: false }, default", function() {
- expect( 2 );
+QUnit.test( "{ axis: false }, default", function( assert ) {
+ assert.expect( 2 );
var element = $( "#draggable2" ).draggable( { axis: false } );
- testHelper.shouldMove( element, "axis: false" );
+ testHelper.shouldMove( assert, element, "axis: false" );
} );
-test( "{ axis: 'x' }", function() {
- expect( 2 );
+QUnit.test( "{ axis: 'x' }", function( assert ) {
+ assert.expect( 2 );
var element = $( "#draggable2" ).draggable( { axis: "x" } );
- testHelper.testDrag( element, element, 50, 50, 50, 0, "axis: x" );
+ testHelper.testDrag( assert, element, element, 50, 50, 50, 0, "axis: x" );
} );
-test( "{ axis: 'y' }", function() {
- expect( 2 );
+QUnit.test( "{ axis: 'y' }", function( assert ) {
+ assert.expect( 2 );
var element = $( "#draggable2" ).draggable( { axis: "y" } );
- testHelper.testDrag( element, element, 50, 50, 0, 50, "axis: y" );
+ testHelper.testDrag( assert, element, element, 50, 50, 0, 50, "axis: y" );
} );
-test( "{ axis: ? }, unexpected", function() {
+QUnit.test( "{ axis: ? }, unexpected", function( assert ) {
var element,
unexpected = {
"true": true,
"function() {}": function() {}
};
- expect( 12 );
+ assert.expect( 12 );
$.each( unexpected, function( key, val ) {
element = $( "#draggable2" ).draggable( { axis: val } );
- testHelper.shouldMove( element, "axis: " + key );
+ testHelper.shouldMove( assert, element, "axis: " + key );
element.draggable( "destroy" );
} );
} );
-test( "axis, default, switching after initialization", function() {
- expect( 6 );
+QUnit.test( "axis, default, switching after initialization", function( assert ) {
+ assert.expect( 6 );
var element = $( "#draggable1" ).draggable( { axis: false } );
// Any Direction
- testHelper.shouldMove( element, "axis: default" );
+ testHelper.shouldMove( assert, element, "axis: default" );
// Only horizontal
element.draggable( "option", "axis", "x" );
- testHelper.testDrag( element, element, 50, 50, 50, 0, "axis: x as option" );
+ testHelper.testDrag( assert, element, element, 50, 50, 50, 0, "axis: x as option" );
// Vertical only
element.draggable( "option", "axis", "y" );
- testHelper.testDrag( element, element, 50, 50, 0, 50, "axis: y as option" );
+ testHelper.testDrag( assert, element, element, 50, 50, 0, 50, "axis: y as option" );
} );
-test( "{ cancel: 'input,textarea,button,select,option' }, default", function() {
- expect( 4 );
+QUnit.test( "{ cancel: 'input,textarea,button,select,option' }, default", function( assert ) {
+ assert.expect( 4 );
$( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#qunit-fixture" );
var element = $( "#draggable-option-cancel-default" ).draggable( { cancel: "input,textarea,button,select,option" } );
- testHelper.shouldMove( element, "cancel: default, element dragged" );
+ testHelper.shouldMove( assert, element, "cancel: default, element dragged" );
element.draggable( "destroy" );
element = $( "#draggable-option-cancel-default" ).draggable( { cancel: "input,textarea,button,select,option" } );
- testHelper.shouldNotDrag( element, "cancel: default, input dragged", "#draggable-option-cancel-default input" );
+ testHelper.shouldNotDrag( assert, element, "cancel: default, input dragged", "#draggable-option-cancel-default input" );
element.draggable( "destroy" );
} );
-test( "{ cancel: 'span' }", function() {
- expect( 4 );
+QUnit.test( "{ cancel: 'span' }", function( assert ) {
+ assert.expect( 4 );
var element = $( "#draggable2" ).draggable();
- testHelper.shouldMove( element, "cancel: default, span dragged", "#draggable2 span" );
+ testHelper.shouldMove( assert, element, "cancel: default, span dragged", "#draggable2 span" );
element.draggable( "destroy" );
element = $( "#draggable2" ).draggable( { cancel: "span" } );
- testHelper.shouldNotDrag( element, "cancel: span, span dragged", "#draggable2 span" );
+ testHelper.shouldNotDrag( assert, element, "cancel: span, span dragged", "#draggable2 span" );
} );
-test( "{ cancel: ? }, unexpected", function() {
- expect( 12 );
+QUnit.test( "{ cancel: ? }, unexpected", function( assert ) {
+ assert.expect( 12 );
var element,
unexpected = {
$.each( unexpected, function( key, val ) {
element = $( "#draggable2" ).draggable( { cancel: val } );
- testHelper.shouldMove( element, "cancel: " + key );
+ testHelper.shouldMove( assert, element, "cancel: " + key );
element.draggable( "destroy" );
} );
} );
/*
-test( "{ cancel: Selectors }, matching parent selector", function() {
+Test( "{ cancel: Selectors }, matching parent selector", function() {
expect( 4 );
$( "#wrapping a" ).append( element );
- testHelper.shouldMove( element, "drag span child", "#draggable2 span" );
- testHelper.shouldNotDrag( $( "#draggable2 span a" ), "drag span a" );
- testHelper.shouldNotDrag( $( "#wrapping a" ), "drag wrapping a" );
+ testHelper.shouldMove( assert, element, "drag span child", "#draggable2 span" );
+ testHelper.shouldNotDrag( assert, $( "#draggable2 span a" ), "drag span a" );
+ testHelper.shouldNotDrag( assert, $( "#wrapping a" ), "drag wrapping a" );
$( "#draggable2" ).draggable( "option", "cancel", "span > a" );
$( "#draggable2" ).find( "a" ).append( "<a>" );
- testHelper.shouldMove( element, "drag span child", $( "#draggable2 span a" ).last() );
- testHelper.shouldNotDrag( $( "#draggable2 span a" ).first(), "drag span a first child" );
+ testHelper.shouldMove( assert, element, "drag span child", $( "#draggable2 span a" ).last() );
+ testHelper.shouldNotDrag( assert, $( "#draggable2 span a" ).first(), "drag span a first child" );
});
*/
-test( "cancelement, default, switching after initialization", function() {
- expect( 6 );
+QUnit.test( "cancelement, default, switching after initialization", function( assert ) {
+ assert.expect( 6 );
$( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#qunit-fixture" );
var input = $( "#draggable-option-cancel-default input" ),
element = $( "#draggable-option-cancel-default" ).draggable();
- testHelper.shouldNotDrag( element, "cancel: default, input dragged", input );
+ testHelper.shouldNotDrag( assert, element, "cancel: default, input dragged", input );
element.draggable( "option", "cancel", "textarea" );
- testHelper.shouldMove( element, "cancel: textarea, input dragged", input );
+ testHelper.shouldMove( assert, element, "cancel: textarea, input dragged", input );
element.draggable( "option", "cancel", "input" );
- testHelper.shouldNotDrag( element, "cancel: input, input dragged", input );
+ testHelper.shouldNotDrag( assert, element, "cancel: input, input dragged", input );
} );
-test( "connectToSortable, dragging out of a sortable", function() {
- expect( 4 );
+QUnit.test( "connectToSortable, dragging out of a sortable", function( assert ) {
+ assert.expect( 4 );
var sortItem, dragHelper,
element = $( "#draggableSortable" ).draggable( {
// http://bugs.jqueryui.com/ticket/8809
// Position issue when connected to sortable
- deepEqual( ui.helper.offset(), offsetExpected, "draggable offset is correct" );
+ assert.deepEqual( ui.helper.offset(), offsetExpected, "draggable offset is correct" );
// Http://bugs.jqueryui.com/ticket/7734
// HTML IDs are removed when dragging to a Sortable
- equal( sortItem[ 0 ], dragHelper[ 0 ], "both have the same helper" );
- equal( sortItem.attr( "id" ), dragHelper.attr( "id" ), "both have the same id" );
+ assert.equal( sortItem[ 0 ], dragHelper[ 0 ], "both have the same helper" );
+ assert.equal( sortItem.attr( "id" ), dragHelper.attr( "id" ), "both have the same id" );
// Http://bugs.jqueryui.com/ticket/9481
// connectToSortable causes sortable revert to fail on second attempt
- equal( sortable.sortable( "option", "revert" ), 100, "sortable revert behavior is preserved" );
+ assert.equal( sortable.sortable( "option", "revert" ), 100, "sortable revert behavior is preserved" );
} );
element.simulate( "drag", {
} );
} );
-asyncTest( "connectToSortable, dragging clone into sortable", function() {
- expect( 3 );
+QUnit.test( "connectToSortable, dragging clone into sortable", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 3 );
var offsetPlaceholder,
element = $( "#draggableSortableClone" ).draggable( {
// http://bugs.jqueryui.com/ticket/8809
// Position issue when connected to sortable
- deepEqual( ui.helper.offset(), offsetSortable, "sortable offset is correct" );
- notDeepEqual( ui.helper.offset(), offsetPlaceholder, "offset not equal to placeholder" );
+ assert.deepEqual( ui.helper.offset(), offsetSortable, "sortable offset is correct" );
+ assert.notDeepEqual( ui.helper.offset(), offsetPlaceholder, "offset not equal to placeholder" );
} );
$( sortable ).one( "sortstop", function( event, ui ) {
// http://bugs.jqueryui.com/ticket/9675
// Animation issue with revert and connectToSortable
- deepEqual( ui.item.offset(), offsetPlaceholder, "offset eventually equals placeholder" );
- start();
+ assert.deepEqual( ui.item.offset(), offsetPlaceholder, "offset eventually equals placeholder" );
+ ready();
} );
element.simulate( "drag", {
} );
} );
-test( "connectToSortable, dragging multiple elements in and out of sortable", function() {
- expect( 1 );
+QUnit.test( "connectToSortable, dragging multiple elements in and out of sortable", function( assert ) {
+ assert.expect( 1 );
var element = $( "#draggableSortableClone" ).draggable( {
scroll: false,
// Http://bugs.jqueryui.com/ticket/9675
// Animation issue with revert and connectToSortable
sortable.one( "sortstop", function( event, ui ) {
- ok( !$.contains( document, ui.placeholder[ 0 ] ), "placeholder was removed" );
+ assert.ok( !$.contains( document, ui.placeholder[ 0 ] ), "placeholder was removed" );
} );
// Move the clone of the first element back out
} );
} );
-test( "connectToSortable, dragging through one sortable to a second", function() {
- expect( 2 );
+QUnit.test( "connectToSortable, dragging through one sortable to a second", function( assert ) {
+ assert.expect( 2 );
var overCount = 0,
element = $( "#draggableSortable" ).draggable( {
} );
$( sortable2 ).on( "sortupdate", function() {
- ok( true, "second sortable is updated" );
+ assert.ok( true, "second sortable is updated" );
} );
$( sortable2 ).one( "sortover", function() {
} );
$( sortable2 ).one( "sortstop", function() {
- equal( overCount, 2, "went over both sortables" );
+ assert.equal( overCount, 2, "went over both sortables" );
} );
element.simulate( "drag", dragParams );
} );
-test( "connectToSortable, dragging through a sortable", function() {
- expect( 1 );
+QUnit.test( "connectToSortable, dragging through a sortable", function( assert ) {
+ assert.expect( 1 );
var draggable = $( "#draggableSortable" ).draggable( {
scroll: false,
// Http://bugs.jqueryui.com/ticket/10669
// Draggable: Position issue with connectToSortable
draggable.one( "dragstop", function() {
- equal( draggable.parent().attr( "id" ), "sortable", "restored draggable to original parent" );
+ assert.equal( draggable.parent().attr( "id" ), "sortable", "restored draggable to original parent" );
} );
draggable.simulate( "drag", {
} );
} );
-test( "{ containment: Element }", function() {
- expect( 1 );
+QUnit.test( "{ containment: Element }", function( assert ) {
+ assert.expect( 1 );
var offsetAfter,
element = $( "#draggable1" ).draggable( { containment: $( "#draggable1" ).parent()[ 0 ] } ),
dy: -100
} );
offsetAfter = element.offset();
- deepEqual( offsetAfter, expected, "compare offset to parent" );
+ assert.deepEqual( offsetAfter, expected, "compare offset to parent" );
} );
-test( "{ containment: Selector }", function() {
- expect( 1 );
+QUnit.test( "{ containment: Selector }", function( assert ) {
+ assert.expect( 1 );
var offsetAfter,
element = $( "#draggable1" ).draggable( { containment: $( "#qunit-fixture" ) } ),
dy: -100
} );
offsetAfter = element.offset();
- deepEqual( offsetAfter, expected, "compare offset to parent" );
+ assert.deepEqual( offsetAfter, expected, "compare offset to parent" );
} );
-test( "{ containment: [x1, y1, x2, y2] }", function() {
- expect( 2 );
+QUnit.test( "{ containment: [x1, y1, x2, y2] }", function( assert ) {
+ assert.expect( 2 );
var element = $( "#draggable1" ).draggable(),
eo = element.offset();
element.draggable( "option", "containment", [ eo.left, eo.top, eo.left + element.width() + 5, eo.top + element.height() + 5 ] );
- testHelper.testDrag( element, element, -100, -100, 0, 0, "containment: [x1, y1, x2, y2]" );
+ testHelper.testDrag( assert, element, element, -100, -100, 0, 0, "containment: [x1, y1, x2, y2]" );
} );
-test( "{ containment: 'parent' }, relative", function() {
- expect( 1 );
+QUnit.test( "{ containment: 'parent' }, relative", function( assert ) {
+ assert.expect( 1 );
var offsetAfter,
element = $( "#draggable1" ).draggable( { containment: "parent" } ),
dy: -100
} );
offsetAfter = element.offset();
- deepEqual( offsetAfter, expected, "compare offset to parent" );
+ assert.deepEqual( offsetAfter, expected, "compare offset to parent" );
} );
-test( "{ containment: 'parent' }, absolute", function() {
- expect( 1 );
+QUnit.test( "{ containment: 'parent' }, absolute", function( assert ) {
+ assert.expect( 1 );
var offsetAfter,
element = $( "#draggable2" ).draggable( { containment: "parent" } ),
dy: -100
} );
offsetAfter = element.offset();
- deepEqual( offsetAfter, expected, "compare offset to parent" );
+ assert.deepEqual( offsetAfter, expected, "compare offset to parent" );
} );
-test( "containment, account for border", function( assert ) {
- expect( 2 );
+QUnit.test( "containment, account for border", function( assert ) {
+ assert.expect( 2 );
var el = $( "#draggable1" ).appendTo( "#scrollParent" ),
parent = el.parent().css( {
// http://bugs.jqueryui.com/ticket/7016
// draggable can be pulled out of containment in Chrome and IE8
-test( "containment, element cant be pulled out of container", function() {
- expect( 1 );
+QUnit.test( "containment, element cant be pulled out of container", function( assert ) {
+ assert.expect( 1 );
var offsetBefore,
parent = $( "<div>" ).css( { width: 200, height: 200 } ).appendTo( "#qunit-fixture" ),
dy: 200
} );
- deepEqual( element.offset(), offsetBefore, "The draggable should not move past bottom right edge" );
+ assert.deepEqual( element.offset(), offsetBefore, "The draggable should not move past bottom right edge" );
} );
-test( "containment, default, switching after initialization", function() {
- expect( 8 );
+QUnit.test( "containment, default, switching after initialization", function( assert ) {
+ assert.expect( 8 );
var element = $( "#draggable1" ).draggable( { containment: false, scroll: false } ),
po = element.parent().offset(),
containment = [ po.left - 100, po.top - 100, po.left + 500, po.top + 500 ];
- testHelper.testDrag( element, element, -100, -100, -100, -100, "containment: default" );
+ testHelper.testDrag( assert, element, element, -100, -100, -100, -100, "containment: default" );
element.draggable( "option", "containment", "parent" ).css( { top: 0, left: 0 } );
- testHelper.testDrag( element, element, -100, -100, 0, 0, "containment: parent as option" );
+ testHelper.testDrag( assert, element, element, -100, -100, 0, 0, "containment: parent as option" );
element.draggable( "option", "containment", containment ).css( { top: 0, left: 0 } );
- testHelper.testDrag( element, element, -100, -100, -100, -100, "containment: array as option" );
+ testHelper.testDrag( assert, element, element, -100, -100, -100, -100, "containment: array as option" );
element.draggable( "option", "containment", false );
- testHelper.testDrag( element, element, -100, -100, -100, -100, "containment: false as option" );
+ testHelper.testDrag( assert, element, element, -100, -100, -100, -100, "containment: false as option" );
} );
-test( "{ cursor: 'auto' }, default", function() {
+QUnit.test( "{ cursor: 'auto' }, default", function( assert ) {
function getCursor() {
return $( "#draggable2" ).css( "cursor" );
}
- expect( 2 );
+ assert.expect( 2 );
var actual, after,
expected = "auto",
} );
after = getCursor();
- equal( actual, expected, "start callback: cursor '" + expected + "'" );
- equal( after, before, "after drag: cursor restored" );
+ assert.equal( actual, expected, "start callback: cursor '" + expected + "'" );
+ assert.equal( after, before, "after drag: cursor restored" );
} );
-test( "{ cursor: 'move' }", function() {
+QUnit.test( "{ cursor: 'move' }", function( assert ) {
function getCursor() {
return $( "body" ).css( "cursor" );
}
- expect( 2 );
+ assert.expect( 2 );
var actual, after,
expected = "move",
} );
after = getCursor();
- equal( actual, expected, "start callback: cursor '" + expected + "'" );
- equal( after, before, "after drag: cursor restored" );
+ assert.equal( actual, expected, "start callback: cursor '" + expected + "'" );
+ assert.equal( after, before, "after drag: cursor restored" );
} );
-test( "#6889: Cursor doesn't revert to pre-dragging state after revert action when original element is removed", function() {
+QUnit.test( "#6889: Cursor doesn't revert to pre-dragging state after revert action when original element is removed", function( assert ) {
function getCursor() {
return $( "body" ).css( "cursor" );
}
- expect( 2 );
+ assert.expect( 2 );
var element = $( "#draggable1" ).wrap( "<div id='wrapper' />" ).draggable( {
cursor: "move",
revert: true,
revertDuration: 0,
start: function() {
- notEqual( getCursor(), expected, "start callback: cursor '" + expected + "'" );
+ assert.notEqual( getCursor(), expected, "start callback: cursor '" + expected + "'" );
$( "#wrapper" ).remove();
},
stop: function() {
- equal( getCursor(), expected, "after drag: cursor restored" );
+ assert.equal( getCursor(), expected, "after drag: cursor restored" );
}
} ),
expected = getCursor();
if ( testHelper.unreliableContains ) {
- ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
- ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
+ assert.ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
+ assert.ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
} else {
element.simulate( "drag", {
dx: -1,
}
} );
-test( "cursor, default, switching after initialization", function() {
- expect( 3 );
+QUnit.test( "cursor, default, switching after initialization", function( assert ) {
+ assert.expect( 3 );
var element = $( "#draggable1" ).draggable();
testHelper.trackMouseCss( element );
testHelper.move( element, 1, 1 );
- equal( element.data( "last_dragged_cursor" ), "auto" );
+ assert.equal( element.data( "last_dragged_cursor" ), "auto" );
element.draggable( "option", "cursor", "move" );
testHelper.move( element, 1, 1 );
- equal( element.data( "last_dragged_cursor" ), "move" );
+ assert.equal( element.data( "last_dragged_cursor" ), "move" );
element.draggable( "option", "cursor", "ns-resize" );
testHelper.move( element, 1, 1 );
- equal( element.data( "last_dragged_cursor" ), "ns-resize" );
+ assert.equal( element.data( "last_dragged_cursor" ), "ns-resize" );
} );
-test( "cursorAt", function() {
- expect( 24 );
+QUnit.test( "cursorAt", function( assert ) {
+ assert.expect( 24 );
var deltaX = -3,
deltaY = -3,
cursorAt: testData.cursorAt,
drag: function( event, ui ) {
if ( !testData.cursorAt ) {
- equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" );
- equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" );
+ assert.equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" );
+ assert.equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" );
} else if ( testData.cursorAt.right ) {
- equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - testHelper.unreliableOffset, testName + " " + position + " left" );
- equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - testHelper.unreliableOffset, testName + " " + position + " top" );
+ assert.equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - testHelper.unreliableOffset, testName + " " + position + " left" );
+ assert.equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - testHelper.unreliableOffset, testName + " " + position + " top" );
} else {
- equal( event.clientX - ui.offset.left, testData.x + testHelper.unreliableOffset, testName + " " + position + " left" );
- equal( event.clientY - ui.offset.top, testData.y + testHelper.unreliableOffset, testName + " " + position + " top" );
+ assert.equal( event.clientX - ui.offset.left, testData.x + testHelper.unreliableOffset, testName + " " + position + " left" );
+ assert.equal( event.clientY - ui.offset.top, testData.y + testHelper.unreliableOffset, testName + " " + position + " top" );
}
}
} );
} );
} );
-test( "cursorAt, switching after initialization", function() {
- expect( 24 );
+QUnit.test( "cursorAt, switching after initialization", function( assert ) {
+ assert.expect( 24 );
var deltaX = -3,
deltaY = -3,
element.draggable( {
drag: function( event, ui ) {
if ( !testData.cursorAt ) {
- equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" );
- equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" );
+ assert.equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" );
+ assert.equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" );
} else if ( testData.cursorAt.right ) {
- equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - testHelper.unreliableOffset, testName + " " + position + " left" );
- equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - testHelper.unreliableOffset, testName + " " + position + " top" );
+ assert.equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - testHelper.unreliableOffset, testName + " " + position + " left" );
+ assert.equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - testHelper.unreliableOffset, testName + " " + position + " top" );
} else {
- equal( event.clientX - ui.offset.left, testData.x + testHelper.unreliableOffset, testName + " " + position + " left" );
- equal( event.clientY - ui.offset.top, testData.y + testHelper.unreliableOffset, testName + " " + position + " top" );
+ assert.equal( event.clientX - ui.offset.left, testData.x + testHelper.unreliableOffset, testName + " " + position + " left" );
+ assert.equal( event.clientY - ui.offset.top, testData.y + testHelper.unreliableOffset, testName + " " + position + " top" );
}
}
} );
} );
} );
-test( "disabled", function() {
- expect( 6 );
+QUnit.test( "disabled", function( assert ) {
+ assert.expect( 6 );
var element = $( "#draggable1" ).draggable();
- testHelper.shouldMove( element, "disabled: default" );
+ testHelper.shouldMove( assert, element, "disabled: default" );
element.draggable( "option", "disabled", true );
- testHelper.shouldNotDrag( element, "option: disabled true" );
+ testHelper.shouldNotDrag( assert, element, "option: disabled true" );
element.draggable( "option", "disabled", false );
- testHelper.shouldMove( element, "option: disabled false" );
+ testHelper.shouldMove( assert, element, "option: disabled false" );
} );
-test( "{ grid: [50, 50] }, relative", function() {
- expect( 4 );
+QUnit.test( "{ grid: [50, 50] }, relative", function( assert ) {
+ assert.expect( 4 );
var element = $( "#draggable1" ).draggable( { grid: [ 50, 50 ] } );
- testHelper.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] relative" );
- testHelper.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] relative" );
+ testHelper.testDrag( assert, element, element, 24, 24, 0, 0, "grid: [50, 50] relative" );
+ testHelper.testDrag( assert, element, element, 26, 25, 50, 50, "grid: [50, 50] relative" );
} );
-test( "{ grid: [50, 50] }, absolute", function() {
- expect( 4 );
+QUnit.test( "{ grid: [50, 50] }, absolute", function( assert ) {
+ assert.expect( 4 );
var element = $( "#draggable2" ).draggable( { grid: [ 50, 50 ] } );
- testHelper.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] absolute" );
- testHelper.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] absolute" );
+ testHelper.testDrag( assert, element, element, 24, 24, 0, 0, "grid: [50, 50] absolute" );
+ testHelper.testDrag( assert, element, element, 26, 25, 50, 50, "grid: [50, 50] absolute" );
} );
-test( "grid, switching after initialization", function() {
- expect( 8 );
+QUnit.test( "grid, switching after initialization", function( assert ) {
+ assert.expect( 8 );
var element = $( "#draggable1" ).draggable();
// Forward
- testHelper.testDrag( element, element, 24, 24, 24, 24, "grid: default" );
- testHelper.testDrag( element, element, 0, 0, 0, 0, "grid: default" );
+ testHelper.testDrag( assert, element, element, 24, 24, 24, 24, "grid: default" );
+ testHelper.testDrag( assert, element, element, 0, 0, 0, 0, "grid: default" );
element.draggable( "option", "grid", [ 50, 50 ] );
- testHelper.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] as option" );
- testHelper.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] as option" );
+ testHelper.testDrag( assert, element, element, 24, 24, 0, 0, "grid: [50, 50] as option" );
+ testHelper.testDrag( assert, element, element, 26, 25, 50, 50, "grid: [50, 50] as option" );
} );
-test( "{ handle: 'span' }", function() {
- expect( 6 );
+QUnit.test( "{ handle: 'span' }", function( assert ) {
+ assert.expect( 6 );
var element = $( "#draggable2" ).draggable( { handle: "span" } );
- testHelper.shouldMove( element, "handle: span", "#draggable2 span" );
- testHelper.shouldMove( element, "handle: span child", "#draggable2 span em" );
- testHelper.shouldNotDrag( element, "handle: span element" );
+ testHelper.shouldMove( assert, element, "handle: span", "#draggable2 span" );
+ testHelper.shouldMove( assert, element, "handle: span child", "#draggable2 span em" );
+ testHelper.shouldNotDrag( assert, element, "handle: span element" );
} );
-test( "handle, default, switching after initialization", function() {
- expect( 12 );
+QUnit.test( "handle, default, switching after initialization", function( assert ) {
+ assert.expect( 12 );
var element = $( "#draggable2" ).draggable();
- testHelper.shouldMove( element, "handle: default, element dragged" );
- testHelper.shouldMove( element, "handle: default, span dragged", "#draggable2 span" );
+ testHelper.shouldMove( assert, element, "handle: default, element dragged" );
+ testHelper.shouldMove( assert, element, "handle: default, span dragged", "#draggable2 span" );
// Switch
element.draggable( "option", "handle", "span" );
- testHelper.shouldNotDrag( element, "handle: span as option, element dragged" );
- testHelper.shouldMove( element, "handle: span as option, span dragged", "#draggable2 span" );
+ testHelper.shouldNotDrag( assert, element, "handle: span as option, element dragged" );
+ testHelper.shouldMove( assert, element, "handle: span as option, span dragged", "#draggable2 span" );
// And back
element.draggable( "option", "handle", false );
- testHelper.shouldMove( element, "handle: false as option, element dragged" );
- testHelper.shouldMove( element, "handle: false as option, span dragged", "#draggable2 span" );
+ testHelper.shouldMove( assert, element, "handle: false as option, element dragged" );
+ testHelper.shouldMove( assert, element, "handle: false as option, span dragged", "#draggable2 span" );
} );
-test( "helper, default, switching after initialization", function() {
- expect( 6 );
+QUnit.test( "helper, default, switching after initialization", function( assert ) {
+ assert.expect( 6 );
var element = $( "#draggable1" ).draggable();
- testHelper.shouldMove( element, "helper: default" );
+ testHelper.shouldMove( assert, element, "helper: default" );
element.draggable( "option", "helper", "clone" );
- testHelper.shouldMove( element, "helper: clone" );
+ testHelper.shouldMove( assert, element, "helper: clone" );
element.draggable( "option", "helper", "original" );
- testHelper.shouldMove( element, "helper: original" );
+ testHelper.shouldMove( assert, element, "helper: original" );
} );
// http://bugs.jqueryui.com/ticket/9446
// Draggable: helper function cannot emulate default behavior
-test( "helper, function returning original element", function() {
- expect( 1 );
+QUnit.test( "helper, function returning original element", function( assert ) {
+ assert.expect( 1 );
var element = $( "#draggable1" ).css( "position", "static" ).draggable( {
helper: function() {
}
} );
- testHelper.testDragHelperOffset( element, 100, 100, 100, 100, "original element is draggable" );
+ testHelper.testDragHelperOffset( assert, element, 100, 100, 100, 100, "original element is draggable" );
element.simulate( "drag", {
dx: 100,
} );
function testHelperPosition( scrollPositions, position, helper, scrollElements, scrollElementsTitle ) {
- test( "{ helper: '" + helper + "' }, " + position + ", with scroll offset on " + scrollElementsTitle, function() {
- expect( scrollPositions.length * 2 );
+ QUnit.test( "{ helper: '" + helper + "' }, " + position + ", with scroll offset on " + scrollElementsTitle, function( assert ) {
+ assert.expect( scrollPositions.length * 2 );
var i, j,
element = $( "#draggable1" ).css( { position: position, top: 0, left: 0 } ).draggable( {
testHelper.setScroll( scrollElements[ i ] );
}
- testHelper.testScroll( element, scrollPositions[ j ] );
+ testHelper.testScroll( assert, element, scrollPositions[ j ] );
for ( i = 0; i < scrollElements.length; i++ ) {
testHelper.restoreScroll( scrollElements[ i ] );
positions = [ "absolute", "fixed", "relative", "static" ],
helpers = [ "original", "clone" ],
- // static is not an option here since the fixture is in an absolute container
+ // Static is not an option here since the fixture is in an absolute container
scrollPositions = [ "relative", "absolute", "fixed" ];
$.each( helpers, function() {
} );
} )();
-test( "{ opacity: 0.5 }", function() {
- expect( 1 );
+QUnit.test( "{ opacity: 0.5 }", function( assert ) {
+ assert.expect( 1 );
var opacity = null,
element = $( "#draggable2" ).draggable( {
dy: -1
} );
- equal( opacity, 0.5, "start callback: opacity is" );
+ assert.equal( opacity, 0.5, "start callback: opacity is" );
} );
-test( "opacity, default, switching after initialization", function() {
- expect( 3 );
+QUnit.test( "opacity, default, switching after initialization", function( assert ) {
+ assert.expect( 3 );
var opacity = null,
element = $( "#draggable2" ).draggable( {
} );
testHelper.move( element, 1, 1 );
- equal( opacity, 1 );
+ assert.equal( opacity, 1 );
element.draggable( "option", "opacity", 0.5 );
testHelper.move( element, 2, 1 );
- equal( opacity, 0.5 );
+ assert.equal( opacity, 0.5 );
element.draggable( "option", "opacity", false );
testHelper.move( element, 3, 1 );
- equal( opacity, 1 );
+ assert.equal( opacity, 1 );
} );
-asyncTest( "revert and revertDuration", function() {
- expect( 7 );
+QUnit.test( "revert and revertDuration", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 7 );
var element = $( "#draggable2" ).draggable( {
revert: true,
revertDuration: 0
} );
- testHelper.shouldMovePositionButNotOffset( element, "revert: true, revertDuration: 0 should revert immediately" );
+ testHelper.shouldMovePositionButNotOffset( assert, element, "revert: true, revertDuration: 0 should revert immediately" );
$( "#draggable2" ).draggable( "option", "revert", "invalid" );
- testHelper.shouldMovePositionButNotOffset( element, "revert: invalid, revertDuration: 0 should revert immediately" );
+ testHelper.shouldMovePositionButNotOffset( assert, element, "revert: invalid, revertDuration: 0 should revert immediately" );
$( "#draggable2" ).draggable( "option", "revert", false );
- testHelper.shouldMove( element, "revert: false should allow movement" );
+ testHelper.shouldMove( assert, element, "revert: false should allow movement" );
$( "#draggable2" ).draggable( "option", {
revert: true,
revertDuration: 200,
stop: function() {
- start();
+ ready();
}
} );
// Animation are async, so test for it asynchronously
testHelper.move( element, 50, 50 );
setTimeout( function() {
- ok( $( "#draggable2" ).is( ":animated" ), "revert: true with revertDuration should animate" );
+ assert.ok( $( "#draggable2" ).is( ":animated" ), "revert: true with revertDuration should animate" );
} );
} );
-test( "revert: valid", function() {
- expect( 2 );
+QUnit.test( "revert: valid", function( assert ) {
+ assert.expect( 2 );
var element = $( "#draggable2" ).draggable( {
revert: "valid",
$( "#droppable" ).droppable();
- testHelper.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable" );
+ testHelper.shouldMovePositionButNotOffset( assert, element, "revert: valid reverts when dropped on a droppable" );
} );
-test( "scope", function() {
- expect( 4 );
+QUnit.test( "scope", function( assert ) {
+ assert.expect( 4 );
var element = $( "#draggable2" ).draggable( {
scope: "tasks",
$( "#droppable" ).droppable( { scope: "tasks" } );
- testHelper.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable in scope" );
+ testHelper.shouldMovePositionButNotOffset( assert, element, "revert: valid reverts when dropped on a droppable in scope" );
$( "#droppable" ).droppable( "destroy" ).droppable( { scope: "nottasks" } );
- testHelper.shouldMove( element, "revert: valid reverts when dropped on a droppable out of scope" );
+ testHelper.shouldMove( assert, element, "revert: valid reverts when dropped on a droppable out of scope" );
} );
-test( "scroll, scrollSensitivity, and scrollSpeed", function() {
- expect( 2 );
+QUnit.test( "scroll, scrollSensitivity, and scrollSpeed", function( assert ) {
+ assert.expect( 2 );
testHelper.setScrollable( "#main", false );
} );
$( element ).one( "drag", function() {
- equal( $( window ).scrollTop(), 0, "scroll: true doesn't scroll when the element is dragged outside of scrollSensitivity" );
+ assert.equal( $( window ).scrollTop(), 0, "scroll: true doesn't scroll when the element is dragged outside of scrollSensitivity" );
} );
element.simulate( "drag", {
currentScrollTop = $( window ).scrollTop();
$( element ).one( "drag", function() {
- ok( $( window ).scrollTop() - currentScrollTop, scrollSpeed, "scroll: true scrolls when the element is dragged within scrollSensitivity" );
+ assert.ok( $( window ).scrollTop() - currentScrollTop, scrollSpeed, "scroll: true scrolls when the element is dragged within scrollSensitivity" );
} );
element.simulate( "drag", {
testHelper.restoreScroll( document );
} );
-test( "scroll ignores containers that are overflow: hidden", function() {
- expect( 2 );
+QUnit.test( "scroll ignores containers that are overflow: hidden", function( assert ) {
+ assert.expect( 2 );
var scrollParent = $( "#scrollParent" ),
element = $( "#draggable1" ).draggable().appendTo( scrollParent );
// container, so skip this test if native scroll occurs.
// Support: IE <9
if ( scrollParent.scrollTop() > 0 ) {
- ok( true, "overflow:hidden container natively scrolls" );
- ok( true, "overflow:hidden container natively scrolls" );
+ assert.ok( true, "overflow:hidden container natively scrolls" );
+ assert.ok( true, "overflow:hidden container natively scrolls" );
return;
}
dy: 1300
} );
- equal( scrollParent.scrollTop(), 0, "container doesn't scroll vertically" );
- equal( scrollParent.scrollLeft(), 0, "container doesn't scroll horizontally" );
+ assert.equal( scrollParent.scrollTop(), 0, "container doesn't scroll vertically" );
+ assert.equal( scrollParent.scrollLeft(), 0, "container doesn't scroll horizontally" );
} );
-test( "#6817: auto scroll goes double distance when dragging", function( assert ) {
- expect( 2 );
+QUnit.test( "#6817: auto scroll goes double distance when dragging", function( assert ) {
+ assert.expect( 2 );
testHelper.restoreScroll( document );
element = $( "#draggable1" ).draggable( {
scroll: true,
stop: function( e, ui ) {
- equal( ui.offset.top, newY, "offset of item matches pointer position after scroll" );
+ assert.equal( ui.offset.top, newY, "offset of item matches pointer position after scroll" );
// TODO: fix IE8 testswarm IFRAME positioning bug so assert.close can be turned back to equal
assert.close( ui.offset.top - offsetBefore.top, distance, 1, "offset of item only moves expected distance after scroll" );
testHelper.restoreScroll( document );
} );
-test( "snap, snapMode, and snapTolerance", function( assert ) {
- expect( 10 );
+QUnit.test( "snap, snapMode, and snapTolerance", function( assert ) {
+ assert.expect( 10 );
var newX, newY,
snapTolerance = 15,
moves: 1
} );
- notDeepEqual( element.offset(), { top: newY, left: newX }, "snaps inside the snapTolerance" );
+ assert.notDeepEqual( element.offset(), { top: newY, left: newX }, "snaps inside the snapTolerance" );
element.draggable( "option", "snap", "#draggable2" );
moves: 1
} );
- notDeepEqual( element.offset(), { top: newY, left: newX }, "snaps based on selector" );
+ assert.notDeepEqual( element.offset(), { top: newY, left: newX }, "snaps based on selector" );
element.draggable( "option", "snap", "#draggable3" );
moves: 1
} );
- deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap based on invalid selector" );
+ assert.deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap based on invalid selector" );
element.draggable( "option", "snap", true );
element.draggable( "option", "snapTolerance", snapTolerance - 2 );
moves: 1
} );
- deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap outside the modified snapTolerance" );
+ assert.deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap outside the modified snapTolerance" );
element.draggable( "option", "snapTolerance", snapTolerance );
element.draggable( "option", "snapMode", "inner" );
moves: 1
} );
- deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap inside the outer snapTolerance area when snapMode is inner" );
+ assert.deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap inside the outer snapTolerance area when snapMode is inner" );
newX = element2.offset().left - snapTolerance - 1;
newY = element2.offset().top;
moves: 1
} );
- deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap inside the outer snapTolerance area when snapMode is inner" );
+ assert.deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap inside the outer snapTolerance area when snapMode is inner" );
newX++;
moves: 1
} );
- notDeepEqual( element.offset(), { top: newY, left: newX }, "snaps inside the inner snapTolerance area when snapMode is inner" );
+ assert.notDeepEqual( element.offset(), { top: newY, left: newX }, "snaps inside the inner snapTolerance area when snapMode is inner" );
element.draggable( "option", "snapMode", "outer" );
moves: 1
} );
- deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap on the inner snapTolerance area when snapMode is outer" );
+ assert.deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap on the inner snapTolerance area when snapMode is outer" );
} );
-test( "#8459: element can snap to an element that was removed during drag", function( assert ) {
- expect( 2 );
+QUnit.test( "#8459: element can snap to an element that was removed during drag", function( assert ) {
+ assert.expect( 2 );
var newX, newY,
snapTolerance = 15,
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
if ( testHelper.unreliableContains ) {
- ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
- ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
+ assert.ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
+ assert.ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
} else {
// TODO: fix IE8 testswarm IFRAME positioning bug so assert.close can be turned back to equal
}
} );
-test( "#8165: Snapping large rectangles to small rectangles doesn't snap properly", function() {
- expect( 1 );
+QUnit.test( "#8165: Snapping large rectangles to small rectangles doesn't snap properly", function( assert ) {
+ assert.expect( 1 );
var snapTolerance = 20,
y = 1,
moves: 1
} );
- notDeepEqual( element.offset(), { top: y, left: newX }, "snaps even if only a side (not a corner) is inside the snapTolerance" );
+ assert.notDeepEqual( element.offset(), { top: y, left: newX }, "snaps even if only a side (not a corner) is inside the snapTolerance" );
} );
-test( "stack", function() {
- expect( 2 );
+QUnit.test( "stack", function( assert ) {
+ assert.expect( 2 );
var element = $( "#draggable1" ).draggable( {
stack: "#draggable1, #draggable2"
} );
testHelper.move( element, 1, 1 );
- equal( element.css( "zIndex" ), "2", "stack increments zIndex correctly" );
+ assert.equal( element.css( "zIndex" ), "2", "stack increments zIndex correctly" );
testHelper.move( element2, 1, 1 );
- equal( element2.css( "zIndex" ), "3", "stack increments zIndex correctly" );
+ assert.equal( element2.css( "zIndex" ), "3", "stack increments zIndex correctly" );
} );
-test( "{ zIndex: 10 }", function() {
- expect( 1 );
+QUnit.test( "{ zIndex: 10 }", function( assert ) {
+ assert.expect( 1 );
var actual,
expected = 10,
dy: -1
} );
- equal( actual, expected, "start callback: zIndex is" );
+ assert.equal( actual, expected, "start callback: zIndex is" );
} );
-test( "zIndex, default, switching after initialization", function() {
+QUnit.test( "zIndex, default, switching after initialization", function( assert ) {
- expect( 3 );
+ assert.expect( 3 );
var zindex = null,
element = $( "#draggable2" ).draggable( {
element.css( "z-index", 1 );
testHelper.move( element, 1, 1 );
- equal( zindex, 1 );
+ assert.equal( zindex, 1 );
element.draggable( "option", "zIndex", 5 );
testHelper.move( element, 2, 1 );
- equal( zindex, 5 );
+ assert.equal( zindex, 5 );
element.draggable( "option", "zIndex", false );
testHelper.move( element, 3, 1 );
- equal( zindex, 1 );
+ assert.equal( zindex, 1 );
} );
-test( "iframeFix", function() {
- expect( 5 );
+QUnit.test( "iframeFix", function( assert ) {
+ assert.expect( 5 );
var element = $( "<div>" ).appendTo( "#qunit-fixture" ).draggable( { iframeFix: true } ),
element2 = $( "<div>" ).appendTo( "#qunit-fixture" ).draggable( { iframeFix: ".iframe" } ),
// http://bugs.jqueryui.com/ticket/9671
// iframeFix doesn't handle iframes that move
- equal( div.length, 1, "blocking div added as sibling" );
- equal( div.outerWidth(), iframe.outerWidth(), "blocking div is wide enough" );
- equal( div.outerHeight(), iframe.outerHeight(), "blocking div is tall enough" );
- deepEqual( div.offset(), iframe.offset(), "blocking div is tall enough" );
+ assert.equal( div.length, 1, "blocking div added as sibling" );
+ assert.equal( div.outerWidth(), iframe.outerWidth(), "blocking div is wide enough" );
+ assert.equal( div.outerHeight(), iframe.outerHeight(), "blocking div is tall enough" );
+ assert.deepEqual( div.offset(), iframe.offset(), "blocking div is tall enough" );
} );
element.simulate( "drag", {
element2.one( "drag", function() {
var div = $( this ).children().not( "iframe" );
- equal( div.length, 1, "blocking div added as sibling only to matching selector" );
+ assert.equal( div.length, 1, "blocking div added as sibling only to matching selector" );
} );
element2.simulate( "drag", {