diff options
author | Mike Sherov <mike.sherov@gmail.com> | 2014-08-10 20:40:55 -0400 |
---|---|---|
committer | Mike Sherov <mike.sherov@gmail.com> | 2014-08-10 20:41:23 -0400 |
commit | 454b58ee66c08453c149f592f9c39f011226ce57 (patch) | |
tree | a94022854a2618a2c5b96e2205475e7aa172d8b8 /tests | |
parent | 36e4bfd516c10140d8517ed9e2eb067be2e5c837 (diff) | |
download | jquery-ui-454b58ee66c08453c149f592f9c39f011226ce57.tar.gz jquery-ui-454b58ee66c08453c149f592f9c39f011226ce57.zip |
Droppable tests: swap $.ui.intersect test with tolerance test
$.ui.intersect is not a documented API, yet droppable tolerance is,
and are essentially the same.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/droppable/droppable_methods.js | 29 | ||||
-rw-r--r-- | tests/unit/droppable/droppable_options.js | 41 |
2 files changed, 39 insertions, 31 deletions
diff --git a/tests/unit/droppable/droppable_methods.js b/tests/unit/droppable/droppable_methods.js index ce3d8f72f..a8a2a078c 100644 --- a/tests/unit/droppable/droppable_methods.js +++ b/tests/unit/droppable/droppable_methods.js @@ -88,33 +88,4 @@ test( "disable", function() { equal( actual, expected, "disable is chainable" ); }); -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 ); diff --git a/tests/unit/droppable/droppable_options.js b/tests/unit/droppable/droppable_options.js index 1d8f95da9..e4c83dbc9 100644 --- a/tests/unit/droppable/droppable_options.js +++ b/tests/unit/droppable/droppable_options.js @@ -93,11 +93,48 @@ test("tolerance, fit", function() { test("tolerance, intersect", function() { ok(false, 'missing test - untested code is broken code'); }); +*/ -test("tolerance, pointer", function() { - ok(false, 'missing test - untested code is broken code'); +test( "tolerance, pointer", function() { + expect( 2 ); + + var draggable, 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" ] + ]; + + 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({ tolerance: "pointer" }); + + $.each( dataset, function() { + var data = this; + + droppable.unbind( "drop" ).bind( "drop", function() { + equal( true, data[ 2 ], data[ 3 ] ); + }); + + $( draggable ).simulate( "drag", { + dx: ( data[ 0 ] - $( draggable ).position().left ), + dy: ( data[ 1 ] - $( draggable ).position().top ) + }); + }); }); +/* test("tolerance, touch", function() { ok(false, 'missing test - untested code is broken code'); }); |