diff options
author | Felix Nagel <info@felixnagel.com> | 2013-04-02 19:42:19 +0200 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2013-04-02 19:42:19 +0200 |
commit | 73c7342bc4418a902bf021c89e7d2c43172e004e (patch) | |
tree | 1c4d622cc91c2cfb76a0ee1e5977ac2b03799551 /tests/unit/draggable | |
parent | 26c528a4a3b712760792c62b005307a2fe0f6ba6 (diff) | |
parent | 09b3533910e887377fc87126608db1ded06f38f6 (diff) | |
download | jquery-ui-73c7342bc4418a902bf021c89e7d2c43172e004e.tar.gz jquery-ui-73c7342bc4418a902bf021c89e7d2c43172e004e.zip |
Merge branch 'master' into selectmenu
Diffstat (limited to 'tests/unit/draggable')
-rw-r--r-- | tests/unit/draggable/draggable_core.js | 41 | ||||
-rw-r--r-- | tests/unit/draggable/draggable_options.js | 26 |
2 files changed, 40 insertions, 27 deletions
diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 2090f2fd9..f22d483a6 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -4,18 +4,7 @@ (function( $ ) { -var relativeElement, absoluteElement; - -module( "draggable: core", { - setup: function() { - relativeElement = $("<div style='width: 200px; height: 100px;'>Relative</div>").appendTo("#qunit-fixture"); - absoluteElement = $("<div style='background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;'><span>Absolute</span></div>").appendTo("#qunit-fixture"); - }, - teardown: function() { - relativeElement.remove(); - absoluteElement.remove(); - } -}); +module( "draggable: core" ); test( "element types", function() { var typeNames = ( @@ -55,18 +44,18 @@ test( "element types", function() { test( "No options, relative", function() { expect( 1 ); - TestHelpers.draggable.shouldMove( relativeElement.draggable() ); + TestHelpers.draggable.shouldMove( $( "#draggable1" ).draggable() ); }); test( "No options, absolute", function() { expect( 1 ); - TestHelpers.draggable.shouldMove( absoluteElement.draggable() ); + TestHelpers.draggable.shouldMove( $( "#draggable2" ).draggable() ); }); test( "resizable handle with complex markup (#8756 / #8757)", function() { expect( 2 ); - relativeElement + $( "#draggable1" ) .append( $("<div>") .addClass("ui-resizable-handle ui-resizable-w") @@ -74,7 +63,7 @@ test( "resizable handle with complex markup (#8756 / #8757)", function() { ); var handle = $(".ui-resizable-w div"), - target = relativeElement.draggable().resizable({ handles: "all" }); + target = $( "#draggable1" ).draggable().resizable({ handles: "all" }); // todo: fix resizable so it doesn't require a mouseover handle.simulate("mouseover").simulate( "drag", { dx: -50 } ); @@ -85,4 +74,24 @@ test( "resizable handle with complex markup (#8756 / #8757)", function() { equal( target.width(), 200, "compare width" ); }); +test( "#8269: Removing draggable element on drop", function() { + expect( 1 ); + + var element = $( "#draggable1" ).wrap( "<div id='wrapper' />" ).draggable(), + dropOffset = $( "#droppable" ).offset(); + + $( "#droppable" ).droppable({ + drop: function() { + $( "#wrapper" ).remove(); + ok( true, "element removed from DOM on drop" ); + } + }); + + element.simulate( "drag", { + handle: "corner", + x: dropOffset.left, + y: dropOffset.top + }); +}); + })( jQuery ); diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index f4fca0b2e..6a0cd593b 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -378,7 +378,7 @@ test( "containment, account for border", function() { }); test( "containment, default, switching after initialization", function() { - expect( 2 ); + expect( 3 ); var element = $( "#draggable1" ).draggable({ containment: false }); @@ -393,9 +393,8 @@ test( "containment, default, switching after initialization", function() { TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0 ); - // TODO: Switching back to false does not update to false - // element.draggable( "option", "containment", false ); - // TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100 ); + element.draggable( "option", "containment", false ); + TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100 ); }); test( "{ cursor: 'auto' }, default", function() { @@ -1057,11 +1056,11 @@ test( "scope", function() { $( "#droppable" ).droppable({ scope: "tasks" }); - TestHelpers.draggable.testDrag( element, element, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable" ); + TestHelpers.draggable.testDrag( element, element, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable in scope" ); $( "#droppable" ).droppable( "destroy" ).droppable({ scope: "nottasks" }); - TestHelpers.draggable.testDrag( element, element, 100, 100, 100, 100, "revert: valid reverts when dropped on a droppable" ); + TestHelpers.draggable.testDrag( element, element, 100, 100, 100, 100, "revert: valid reverts when dropped on a droppable out of scope" ); }); test( "scroll, scrollSensitivity, and scrollSpeed", function() { @@ -1113,7 +1112,8 @@ test( "#6817: auto scroll goes double distance when dragging", function() { scroll: true, stop: function( e, ui ) { equal( ui.offset.top, newY, "offset of item matches pointer position after scroll" ); - equal( ui.offset.top - offsetBefore.top, distance, "offset of item only moves expected distance after scroll" ); + // TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal + closeEnough( ui.offset.top - offsetBefore.top, distance, 1, "offset of item only moves expected distance after scroll" ); } }), scrollSensitivity = element.draggable( "option", "scrollSensitivity" ), @@ -1138,7 +1138,7 @@ test( "#6817: auto scroll goes double distance when dragging", function() { }); test( "snap, snapMode, and snapTolerance", function() { - expect( 9 ); + expect( 10 ); var newX, newY, snapTolerance = 15, @@ -1164,7 +1164,9 @@ test( "snap, snapMode, and snapTolerance", function() { moves: 1 }); - deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap outside the snapTolerance" ); + // TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal + closeEnough( element.offset().left, newX, 1, "doesn't snap outside the snapTolerance" ); + closeEnough( element.offset().top, newY, 1, "doesn't snap outside the snapTolerance" ); newX += 3; @@ -1258,7 +1260,7 @@ test( "snap, snapMode, and snapTolerance", function() { }); test( "#8459: element can snap to an element that was removed during drag", function() { - expect( 1 ); + expect( 2 ); var newX, newY, snapTolerance = 15, @@ -1287,7 +1289,9 @@ test( "#8459: element can snap to an element that was removed during drag", func moves: 1 }); - deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap to a removed element" ); + // TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal + closeEnough( element.offset().left, newX, 1, "doesn't snap to a removed element" ); + closeEnough( element.offset().top, newY, 1, "doesn't snap to a removed element" ); }); test( "#8165: Snapping large rectangles to small rectangles doesn't snap properly", function() { |