From 94f8c4d5e9ef461973a504d65dd906c1120da71d Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 20 Oct 2013 19:33:40 -0400 Subject: Draggable: apply axis options to position instead of style. Fixes #7251 - Draggable: constrained axis option returns incorrect position. --- tests/unit/draggable/draggable_options.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index be7d665d4..1d6f6eab5 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -106,14 +106,28 @@ test( "{ axis: false }, default", function() { }); test( "{ axis: 'x' }", function() { - expect( 2 ); - var element = $( "#draggable2" ).draggable({ axis: "x" }); + expect( 3 ); + var element = $( "#draggable2" ).draggable({ + axis: "x", + // TODO: remove the stop callback when all TestHelpers.draggable.testDrag bugs are fixed + stop: function( event, ui ) { + var expectedPosition = { left: ui.originalPosition.left + 50, top: ui.originalPosition.top }; + deepEqual( ui.position, expectedPosition, "position dragged[50,0] for axis: x" ); + } + }); TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 0, "axis: x" ); }); test( "{ axis: 'y' }", function() { - expect( 2 ); - var element = $( "#draggable2" ).draggable({ axis: "y" }); + expect( 3 ); + var element = $( "#draggable2" ).draggable({ + axis: "y", + // TODO: remove the stop callback when all TestHelpers.draggable.testDrag bugs are fixed + stop: function( event, ui ) { + var expectedPosition = { left: ui.originalPosition.left, top: ui.originalPosition.top + 50 }; + deepEqual( ui.position, expectedPosition, "position dragged[0,50] for axis: y" ); + } + }); TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 50, "axis: y" ); }); -- cgit v1.2.3