Skip to content

Commit 454b58e

Browse files
committed
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.
1 parent 36e4bfd commit 454b58e

File tree

2 files changed

+39
-31
lines changed

2 files changed

+39
-31
lines changed

tests/unit/droppable/droppable_methods.js

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -88,33 +88,4 @@ test( "disable", function() {
8888
equal( actual, expected, "disable is chainable" );
8989
});
9090

91-
test( "intersect", function() {
92-
expect( 8 );
93-
94-
var actual, data,
95-
draggable = $( "<div />" ).appendTo( "#qunit-fixture" ).css({ width: 10, height: 10, position: "absolute" }).draggable(),
96-
droppable = $( "<div />" ).appendTo( "#qunit-fixture" ).css({ width: 10, height: 10, position: "absolute", top: 5, left: 5 }).droppable(),
97-
dataset = [
98-
[ -1, -1, false, "too far up and left" ],
99-
[ -1, 0, false, "too far left" ],
100-
[ 0, -1, false, "too far up" ],
101-
[ 0, 0, true, "top left corner" ],
102-
[ 9, 9, true, "bottom right corner" ],
103-
[ 10, 9, false, "too far right" ],
104-
[ 9, 10, false, "too far down" ],
105-
[ 10, 10, false, "too far down and right" ]
106-
],
107-
x = 0;
108-
109-
for ( ; x < dataset.length; x++ ) {
110-
data = dataset[ x ];
111-
$( draggable ).simulate( "drag", {
112-
dx: ( data[ 0 ] - $( draggable ).position().left ),
113-
dy: ( data[ 1 ] - $( draggable ).position().top )
114-
});
115-
actual = $.ui.intersect( $( draggable ).draggable( "instance" ), $( droppable ).droppable( "instance" ), "pointer" );
116-
equal( actual, data[ 2 ], data[ 3 ] );
117-
}
118-
});
119-
12091
})( jQuery );

tests/unit/droppable/droppable_options.js

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,48 @@ test("tolerance, fit", function() {
9393
test("tolerance, intersect", function() {
9494
ok(false, 'missing test - untested code is broken code');
9595
});
96+
*/
9697

97-
test("tolerance, pointer", function() {
98-
ok(false, 'missing test - untested code is broken code');
98+
test( "tolerance, pointer", function() {
99+
expect( 2 );
100+
101+
var draggable, droppable,
102+
dataset = [
103+
[ -1, -1, false, "too far up and left" ],
104+
[ -1, 0, false, "too far left" ],
105+
[ 0, -1, false, "too far up" ],
106+
[ 0, 0, true, "top left corner" ],
107+
[ 9, 9, true, "bottom right corner" ],
108+
[ 10, 9, false, "too far right" ],
109+
[ 9, 10, false, "too far down" ],
110+
[ 10, 10, false, "too far down and right" ]
111+
];
112+
113+
draggable = $( "<div />" )
114+
.appendTo( "#qunit-fixture" )
115+
.css({ width: 10, height: 10, position: "absolute" })
116+
.draggable();
117+
118+
droppable = $( "<div />" )
119+
.appendTo( "#qunit-fixture" )
120+
.css({ width: 10, height: 10, position: "absolute", top: 5, left: 5 })
121+
.droppable({ tolerance: "pointer" });
122+
123+
$.each( dataset, function() {
124+
var data = this;
125+
126+
droppable.unbind( "drop" ).bind( "drop", function() {
127+
equal( true, data[ 2 ], data[ 3 ] );
128+
});
129+
130+
$( draggable ).simulate( "drag", {
131+
dx: ( data[ 0 ] - $( draggable ).position().left ),
132+
dy: ( data[ 1 ] - $( draggable ).position().top )
133+
});
134+
});
99135
});
100136

137+
/*
101138
test("tolerance, touch", function() {
102139
ok(false, 'missing test - untested code is broken code');
103140
});

0 commit comments

Comments
 (0)