From: Paul Bakaus Date: Sun, 1 Jun 2008 13:45:06 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 1.5.1~248 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=737ff7309ddc9203d59749cbd988045a33b0e40a;p=jquery-ui.git --- diff --git a/ui/tests/draggable.js b/ui/tests/draggable.js index c2059a55e..ba6eaa7f1 100644 --- a/ui/tests/draggable.js +++ b/ui/tests/draggable.js @@ -243,5 +243,80 @@ test("{ cursor: 'move' }", function() { }); +test("{ distance: 10 }", function() { + + expect(2); + + var dragged = false; + $("#draggable2").draggable({ + distance: 10, + start: function(e, ui) { + dragged = true; + } + }); + + drag("#draggable2", -9, -9); + equals(dragged, false, "The draggable should not have moved when moving -9px"); + + drag("#draggable2", -10, -10); + equals(dragged, true, "The draggable should have moved when moving -10px"); + +}); + +test("{ opacity: 0.5 }", function() { + + expect(1); + + var opacity = null; + $("#draggable2").draggable({ + opacity: 0.5, + start: function(e, ui) { + opacity = $(this).css("opacity"); + } + }); + + drag("#draggable2", -1, -1); + + equals(opacity, "0.5", "start callback: opacity is 0.5"); + +}); + +test("{ zIndex: 10 }", function() { + + expect(1); + + var zIndex = null; + $("#draggable2").draggable({ + zIndex: 10, + start: function(e, ui) { + zIndex = $(this).css("zIndex"); + } + }); + + drag("#draggable2", -1, -1); + + equals(zIndex, "10", "start callback: zIndex is 10"); + +}); + +test("callbacks occurance count", function() { + + expect(3); + + var start = 0, stop = 0, dragc = 0; + $("#draggable2").draggable({ + start: function() { start++; }, + drag: function() { dragc++; }, + stop: function() { stop++; } + }); + + drag("#draggable2", 10, 10); + + equals(start, 1, "start callback should happen exactly once"); + equals(dragc, 11, "drag callback should happen exactly 1+10 times (first simultaneously with start)"); + equals(stop, 1, "stop callback should happen exactly once"); + +}); +