aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/draggable/draggable_events.js
diff options
context:
space:
mode:
authorPaul Bakaus <paul.bakaus@googlemail.com>2010-01-28 16:35:59 +0000
committerPaul Bakaus <paul.bakaus@googlemail.com>2010-01-28 16:35:59 +0000
commit9617d150548df1dead1da9743d99abe378b41a3f (patch)
tree3b65e82c17e707743505a9d122b963e4bdbcd245 /tests/unit/draggable/draggable_events.js
parentb72caa0f3d093dfa45cc022f11a4af13225d4ee6 (diff)
downloadjquery-ui-9617d150548df1dead1da9743d99abe378b41a3f.tar.gz
jquery-ui-9617d150548df1dead1da9743d99abe378b41a3f.zip
draggable: implemented #4145 - start,drag and stop events should be preventable
Diffstat (limited to 'tests/unit/draggable/draggable_events.js')
-rw-r--r--tests/unit/draggable/draggable_events.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/unit/draggable/draggable_events.js b/tests/unit/draggable/draggable_events.js
index 79b406e8c..d92d8ee12 100644
--- a/tests/unit/draggable/draggable_events.js
+++ b/tests/unit/draggable/draggable_events.js
@@ -24,4 +24,58 @@ test("callbacks occurance count", function() {
});
+test("stopping the start callback", function() {
+
+ expect(3);
+
+ var start = 0, stop = 0, dragc = 0;
+ el = $("#draggable2").draggable({
+ start: function() { start++; return false; },
+ drag: function() { dragc++; },
+ stop: function() { stop++; }
+ });
+
+ drag(el, 10, 10);
+
+ equals(start, 1, "start callback should happen exactly once");
+ equals(dragc, 0, "drag callback should not happen at all");
+ equals(stop, 0, "stop callback should not happen if there wasnt even a start");
+
+});
+
+test("stopping the drag callback", function() {
+
+ expect(3);
+
+ var start = 0, stop = 0, dragc = 0;
+ el = $("#draggable2").draggable({
+ start: function() { start++;},
+ drag: function() { dragc++; return false; },
+ stop: function() { stop++; }
+ });
+
+ drag(el, 10, 10);
+
+ equals(start, 1, "start callback should happen exactly once");
+ equals(dragc, 1, "drag callback should happen exactly once");
+ equals(stop, 1, "stop callback should happen, as we need to actively stop the drag");
+
+});
+
+test("stopping the stop callback", function() {
+
+ expect(1);
+
+ el = $("#draggable2").draggable({
+ helper: 'clone',
+ stop: function() { return false; }
+ });
+
+ drag(el, 10, 10);
+
+ ok($("#draggable2").data('draggable').helper, "the clone should not be deleted if the stop callback is stopped");
+
+
+});
+
})(jQuery);