Skip to content

Commit 18b8ffd

Browse files
committed
Draggable Tests: Cover all cursorAt option formats.
1 parent 6953589 commit 18b8ffd

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

tests/unit/draggable/draggable_options.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -270,22 +270,16 @@ test("{ cursor: 'move' }", function() {
270270

271271
});
272272

273-
/*
274-
test("{ cursorAt: false}, default", function() {
275-
expect( 1 );
276-
277-
ok(false, "missing test - untested code is broken code");
278-
});
279-
*/
280-
281-
test( "{ cursorAt: left, top }", function() {
282-
expect( 16 );
273+
test( "cursorAt", function() {
274+
expect( 24 );
283275

284276
var deltaX = -3,
285277
deltaY = -3,
286278
tests = {
279+
"false": { cursorAt : false },
287280
"{ left: -5, top: -5 }": { x: -5, y: -5, cursorAt : { left: -5, top: -5 } },
288281
"[ 10, 20 ]": { x: 10, y: 20, cursorAt : [ 10, 20 ] },
282+
"'10 20'": { x: 10, y: 20, cursorAt : "10 20" },
289283
"{ left: 20, top: 40 }": { x: 20, y: 40, cursorAt : { left: 20, top: 40 } },
290284
"{ right: 10, bottom: 20 }": { x: 10, y: 20, cursorAt : { right: 10, bottom: 20 } }
291285
};
@@ -295,9 +289,12 @@ test( "{ cursorAt: left, top }", function() {
295289
var el = $( "#draggable" + ( i + 1 ) ).draggable({
296290
cursorAt: testData.cursorAt,
297291
drag: function( event, ui ) {
298-
if( testData.cursorAt.right ) {
292+
if( !testData.cursorAt ) {
293+
equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" );
294+
equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" );
295+
} else if( testData.cursorAt.right ) {
299296
equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" );
300-
equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - TestHelpers.draggable.unreliableOffset, testName + position + " top" );
297+
equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - TestHelpers.draggable.unreliableOffset, testName + " " +position + " top" );
301298
} else {
302299
equal( event.clientX - ui.offset.left, testData.x + TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" );
303300
equal( event.clientY - ui.offset.top, testData.y + TestHelpers.draggable.unreliableOffset, testName + " " + position + " top" );

0 commit comments

Comments
 (0)