diff options
author | David Hansen <hansede@gmail.com> | 2013-01-23 11:46:10 -0700 |
---|---|---|
committer | Mike Sherov <mike.sherov@gmail.com> | 2013-05-20 21:30:16 -0400 |
commit | 433ef9d433e9baa464cd0b313b82efa6f1d65556 (patch) | |
tree | 1b98b8fb26c946f272619b88dca079e4343940a4 /tests/unit/droppable/droppable_methods.js | |
parent | 2eb89f07341a557084fa3363fe22afe62530654d (diff) | |
download | jquery-ui-433ef9d433e9baa464cd0b313b82efa6f1d65556.tar.gz jquery-ui-433ef9d433e9baa464cd0b313b82efa6f1d65556.zip |
Interactions: Fixed an off-by-one error in isOverAxis.
Diffstat (limited to 'tests/unit/droppable/droppable_methods.js')
-rw-r--r-- | tests/unit/droppable/droppable_methods.js | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/unit/droppable/droppable_methods.js b/tests/unit/droppable/droppable_methods.js index f7682d262..ce3d8f72f 100644 --- a/tests/unit/droppable/droppable_methods.js +++ b/tests/unit/droppable/droppable_methods.js @@ -88,4 +88,33 @@ test( "disable", function() { equal( actual, expected, "disable is chainable" ); }); -})(jQuery); +test( "intersect", function() { + expect( 8 ); + + var actual, data, + draggable = $( "<div />" ).appendTo( "#qunit-fixture" ).css({ width: 10, height: 10, position: "absolute" }).draggable(), + droppable = $( "<div />" ).appendTo( "#qunit-fixture" ).css({ width: 10, height: 10, position: "absolute", top: 5, left: 5 }).droppable(), + dataset = [ + [ -1, -1, false, "too far up and left" ], + [ -1, 0, false, "too far left" ], + [ 0, -1, false, "too far up" ], + [ 0, 0, true, "top left corner" ], + [ 9, 9, true, "bottom right corner" ], + [ 10, 9, false, "too far right" ], + [ 9, 10, false, "too far down" ], + [ 10, 10, false, "too far down and right" ] + ], + x = 0; + + for ( ; x < dataset.length; x++ ) { + data = dataset[ x ]; + $( draggable ).simulate( "drag", { + dx: ( data[ 0 ] - $( draggable ).position().left ), + dy: ( data[ 1 ] - $( draggable ).position().top ) + }); + actual = $.ui.intersect( $( draggable ).draggable( "instance" ), $( droppable ).droppable( "instance" ), "pointer" ); + equal( actual, data[ 2 ], data[ 3 ] ); + } +}); + +})( jQuery ); |