aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMike Sherov <mike.sherov@gmail.com>2014-08-13 19:36:07 -0400
committerMike Sherov <mike.sherov@gmail.com>2014-08-13 19:36:07 -0400
commit4dad6bb99dae280108338c040d016f795d0da328 (patch)
tree201fac7883facbe2e8f12266e08c916b13cad123 /tests
parent98b7a7dd12d8c798eaecfcb743138586d62b868f (diff)
downloadjquery-ui-4dad6bb99dae280108338c040d016f795d0da328.tar.gz
jquery-ui-4dad6bb99dae280108338c040d016f795d0da328.zip
Droppable: Account for draggable margins when detecting hover
Fixes #6876
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/droppable/droppable_options.js53
1 files changed, 51 insertions, 2 deletions
diff --git a/tests/unit/droppable/droppable_options.js b/tests/unit/droppable/droppable_options.js
index 9bfa25881..047858abf 100644
--- a/tests/unit/droppable/droppable_options.js
+++ b/tests/unit/droppable/droppable_options.js
@@ -89,11 +89,60 @@ test( "hoverClass", function() {
test( "tolerance, fit", function() {
ok(false, 'missing test - untested code is broken code');
});
+*/
test( "tolerance, intersect", function() {
- ok(false, 'missing test - untested code is broken code');
+ expect( 2 );
+
+ var draggable, droppable,
+ dataset = [
+ [ 0, 0, false, "too far up and left" ],
+ [ 6, 0, false, "too far up" ],
+ [ 0, 6, false, "too far left" ],
+ [ 6, 6, true, "top left corner" ],
+ [ 14, 14, true, "bottom right corner" ],
+ [ 15, 6, false, "too far right" ],
+ [ 6, 15, false, "too far down" ],
+ [ 15, 15, false, "too far down and right" ]
+ ];
+
+ draggable = $( "<div />" )
+ .appendTo( "#qunit-fixture" )
+ .css({
+ width: 10,
+ height: 10,
+ position: "absolute",
+
+ // http://bugs.jqueryui.com/ticket/6876
+ // Droppable: droppable region is offset by draggables margin
+ marginTop: 3,
+ marginLeft: 3
+ })
+ .draggable();
+
+ droppable = $( "<div />" )
+ .appendTo( "#qunit-fixture" )
+ .css({ width: 10, height: 10, position: "absolute", top: 13, left: 13 })
+ .droppable({ tolerance: "intersect" });
+
+ $.each( dataset, function() {
+ var data = this;
+
+ draggable.css({
+ top: 0,
+ left: 0
+ });
+
+ droppable.unbind( "drop" ).bind( "drop", function() {
+ equal( true, data[ 2 ], data[ 3 ] );
+ });
+
+ $( draggable ).simulate( "drag", {
+ dx: data[ 0 ],
+ dy: data[ 1 ]
+ });
+ });
});
-*/
test( "tolerance, pointer", function() {
expect( 3 );