aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/draggable/draggable_methods.js
diff options
context:
space:
mode:
authorRichard Worth <rdworth@gmail.com>2009-02-01 00:25:58 +0000
committerRichard Worth <rdworth@gmail.com>2009-02-01 00:25:58 +0000
commit79d2a2891aff472b271f23dfc3b3618c906b3d76 (patch)
tree6deb2b984d02f5a3d24de339aed367e9b6ac357b /tests/unit/draggable/draggable_methods.js
parent34a5af87791686a1dd64c988361c69b97359196b (diff)
downloadjquery-ui-79d2a2891aff472b271f23dfc3b3618c906b3d76.tar.gz
jquery-ui-79d2a2891aff472b271f23dfc3b3618c906b3d76.zip
draggable unit tests: created separate file for each module: defaults, events, methods, options, tickets
Diffstat (limited to 'tests/unit/draggable/draggable_methods.js')
-rw-r--r--tests/unit/draggable/draggable_methods.js95
1 files changed, 95 insertions, 0 deletions
diff --git a/tests/unit/draggable/draggable_methods.js b/tests/unit/draggable/draggable_methods.js
new file mode 100644
index 000000000..6a931bfe7
--- /dev/null
+++ b/tests/unit/draggable/draggable_methods.js
@@ -0,0 +1,95 @@
+/*
+ * 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);
+
+ $("<div></div>").appendTo('body').draggable().remove();
+ ok(true, '.draggable() called on element');
+
+ $([]).draggable();
+ ok(true, '.draggable() called on empty collection');
+
+ $("<div></div>").draggable();
+ ok(true, '.draggable() called on disconnected DOMElement');
+
+ $("<div></div>").draggable().draggable("foo");
+ ok(true, 'arbitrary method called after init');
+
+ $("<div></div>").draggable().data("foo.draggable");
+ ok(true, 'arbitrary option getter after init');
+
+ $("<div></div>").draggable().data("foo.draggable", "bar");
+ ok(true, 'arbitrary option setter after init');
+});
+
+test("destroy", function() {
+ expect(6);
+
+ $("<div></div>").appendTo('body').draggable().draggable("destroy").remove();
+ ok(true, '.draggable("destroy") called on element');
+
+ $([]).draggable().draggable("destroy");
+ ok(true, '.draggable("destroy") called on empty collection');
+
+ $("<div></div>").draggable().draggable("destroy");
+ ok(true, '.draggable("destroy") called on disconnected DOMElement');
+
+ $("<div></div>").draggable().draggable("destroy").draggable("foo");
+ ok(true, 'arbitrary method called after destroy');
+
+ $("<div></div>").draggable().draggable("destroy").data("foo.draggable");
+ ok(true, 'arbitrary option getter after destroy');
+
+ $("<div></div>").draggable().draggable("destroy").data("foo.draggable", "bar");
+ ok(true, 'arbitrary option setter after destroy');
+});
+
+test("enable", function() {
+ expect(6);
+ el = $("#draggable2").draggable({ disabled: true });
+ shouldnotmove('.draggable({ disabled: true })');
+ el.draggable("enable");
+ shouldmove('.draggable("enable")');
+ equals(el.data("disabled.draggable"), false, "disabled.draggable getter");
+
+ el.draggable("destroy");
+ el.draggable({ disabled: true });
+ shouldnotmove('.draggable({ disabled: true })');
+ el.data("disabled.draggable", false);
+ equals(el.data("disabled.draggable"), false, "disabled.draggable setter");
+ shouldmove('.data("disabled.draggable", false)');
+});
+
+test("disable", function() {
+ expect(6);
+ el = $("#draggable2").draggable({ disabled: false });
+ shouldmove('.draggable({ disabled: false })');
+ el.draggable("disable");
+ shouldnotmove('.draggable("disable")');
+ equals(el.data("disabled.draggable"), true, "disabled.draggable getter");
+
+ el.draggable("destroy");
+
+ el.draggable({ disabled: false });
+ shouldmove('.draggable({ disabled: false })');
+ el.data("disabled.draggable", true);
+ equals(el.data("disabled.draggable"), true, "disabled.draggable setter");
+ shouldnotmove('.data("disabled.draggable", true)');
+});
+
+})(jQuery);