From 3909e6d89e01e4cd8777377c63037896bb95aa2f Mon Sep 17 00:00:00 2001 From: Leif Johansson Date: Fri, 25 Nov 2011 21:18:19 +0100 Subject: new jq layout --- .../tests/unit/draggable/draggable_methods.js | 99 ++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/draggable/draggable_methods.js (limited to 'src/main/webapp/jquery-ui-1.9pre/tests/unit/draggable/draggable_methods.js') diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/draggable/draggable_methods.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/draggable/draggable_methods.js new file mode 100644 index 0000000..4ffadf0 --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/draggable/draggable_methods.js @@ -0,0 +1,99 @@ +/* + * draggable_methods.js + */ +(function($) { + +function shouldmove(why) { + drag(el, 50, 50); + moved(50, 50, why); +} + +function shouldnotmove(why) { + drag(el, 50, 50); + moved(0, 0, why); +} + +module("draggable: methods"); + +test("init", function() { + expect(6); + + $("
").appendTo('body').draggable().remove(); + ok(true, '.draggable() called on element'); + + $([]).draggable(); + ok(true, '.draggable() called on empty collection'); + + $("
").draggable(); + ok(true, '.draggable() called on disconnected DOMElement'); + + $("
").draggable().draggable("foo"); + ok(true, 'arbitrary method called after init'); + + $("
").draggable().draggable("option", "foo"); + ok(true, 'arbitrary option getter after init'); + + $("
").draggable().draggable("option", "foo", "bar"); + ok(true, 'arbitrary option setter after init'); +}); + +test("destroy", function() { + $("
").appendTo('body').draggable().draggable("destroy").remove(); + ok(true, '.draggable("destroy") called on element'); + + $([]).draggable().draggable("destroy"); + ok(true, '.draggable("destroy") called on empty collection'); + + $("
").draggable().draggable("destroy"); + ok(true, '.draggable("destroy") called on disconnected DOMElement'); + + $("
").draggable().draggable("destroy").draggable("foo"); + ok(true, 'arbitrary method called after destroy'); + + var expected = $('
').draggable(), + actual = expected.draggable('destroy'); + equals(actual, expected, 'destroy is chainable'); +}); + +test("enable", function() { + expect(7); + el = $("#draggable2").draggable({ disabled: true }); + shouldnotmove('.draggable({ disabled: true })'); + el.draggable("enable"); + shouldmove('.draggable("enable")'); + equals(el.draggable("option", "disabled"), false, "disabled option getter"); + + el.draggable("destroy"); + el.draggable({ disabled: true }); + shouldnotmove('.draggable({ disabled: true })'); + el.draggable("option", "disabled", false); + equals(el.draggable("option", "disabled"), false, "disabled option setter"); + shouldmove('.draggable("option", "disabled", false)'); + + var expected = $('
').draggable(), + actual = expected.draggable('enable'); + equals(actual, expected, 'enable is chainable'); +}); + +test("disable", function() { + expect(7); + el = $("#draggable2").draggable({ disabled: false }); + shouldmove('.draggable({ disabled: false })'); + el.draggable("disable"); + shouldnotmove('.draggable("disable")'); + equals(el.draggable("option", "disabled"), true, "disabled option getter"); + + el.draggable("destroy"); + + el.draggable({ disabled: false }); + shouldmove('.draggable({ disabled: false })'); + el.draggable("option", "disabled", true); + equals(el.draggable("option", "disabled"), true, "disabled option setter"); + shouldnotmove('.draggable("option", "disabled", true)'); + + var expected = $('
').draggable(), + actual = expected.draggable('disable'); + equals(actual, expected, 'disable is chainable'); +}); + +})(jQuery); -- cgit v1.1