diff options
author | Mike Sherov <mike.sherov@gmail.com> | 2013-01-01 23:16:12 -0500 |
---|---|---|
committer | Mike Sherov <mike.sherov@gmail.com> | 2013-01-01 23:16:12 -0500 |
commit | 18b8ffd796ba557a7c939d67a1551b54402a7eb9 (patch) | |
tree | 5b1749e4c8103ed183e8bc8b769dbafb883bd913 | |
parent | 695358983e58c9f3d0c6b755ce89fa92adbea0ea (diff) | |
download | jquery-ui-18b8ffd796ba557a7c939d67a1551b54402a7eb9.tar.gz jquery-ui-18b8ffd796ba557a7c939d67a1551b54402a7eb9.zip |
Draggable Tests: Cover all cursorAt option formats.
-rw-r--r-- | tests/unit/draggable/draggable_options.js | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index 36fcb731d..a3f7169f2 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -270,22 +270,16 @@ test("{ cursor: 'move' }", function() { }); -/* -test("{ cursorAt: false}, default", function() { - expect( 1 ); - - ok(false, "missing test - untested code is broken code"); -}); -*/ - -test( "{ cursorAt: left, top }", function() { - expect( 16 ); +test( "cursorAt", function() { + expect( 24 ); var deltaX = -3, deltaY = -3, tests = { + "false": { cursorAt : false }, "{ left: -5, top: -5 }": { x: -5, y: -5, cursorAt : { left: -5, top: -5 } }, "[ 10, 20 ]": { x: 10, y: 20, cursorAt : [ 10, 20 ] }, + "'10 20'": { x: 10, y: 20, cursorAt : "10 20" }, "{ left: 20, top: 40 }": { x: 20, y: 40, cursorAt : { left: 20, top: 40 } }, "{ right: 10, bottom: 20 }": { x: 10, y: 20, cursorAt : { right: 10, bottom: 20 } } }; @@ -295,9 +289,12 @@ test( "{ cursorAt: left, top }", function() { var el = $( "#draggable" + ( i + 1 ) ).draggable({ cursorAt: testData.cursorAt, drag: function( event, ui ) { - if( testData.cursorAt.right ) { + if( !testData.cursorAt ) { + equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" ); + equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" ); + } else if( testData.cursorAt.right ) { equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" ); - equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - TestHelpers.draggable.unreliableOffset, testName + position + " top" ); + equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - TestHelpers.draggable.unreliableOffset, testName + " " +position + " top" ); } else { equal( event.clientX - ui.offset.left, testData.x + TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" ); equal( event.clientY - ui.offset.top, testData.y + TestHelpers.draggable.unreliableOffset, testName + " " + position + " top" ); |