aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Bakaus <paul.bakaus@googlemail.com>2009-02-06 07:39:52 +0000
committerPaul Bakaus <paul.bakaus@googlemail.com>2009-02-06 07:39:52 +0000
commit4701c0bb98ada18842d6c44df60b03d2aac9908c (patch)
treea1f309850d586f86d829352111de50a58164f3fd /tests
parent929c330cd2d535e339b0fb1d0a5cd32904831b55 (diff)
downloadjquery-ui-4701c0bb98ada18842d6c44df60b03d2aac9908c.tar.gz
jquery-ui-4701c0bb98ada18842d6c44df60b03d2aac9908c.zip
sortable: implemented tests for start,stop,beforeStop,change and update
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/sortable/sortable_events.js109
1 files changed, 103 insertions, 6 deletions
diff --git a/tests/unit/sortable/sortable_events.js b/tests/unit/sortable/sortable_events.js
index d55bf816e..f64c50b71 100644
--- a/tests/unit/sortable/sortable_events.js
+++ b/tests/unit/sortable/sortable_events.js
@@ -6,27 +6,124 @@
module("sortable: events");
test("start", function() {
- ok(false, "missing test - untested code is broken code.");
+
+ var hash;
+ $("#sortable")
+ .sortable({ start: function(e, ui) { hash = ui; } })
+ .find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 });
+
+ ok(hash, 'start event triggered');
+ ok(hash.helper, 'UI hash includes: helper');
+ ok(hash.placeholder, 'UI hash includes: placeholder');
+ ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
+ ok(hash.absolutePosition && (hash.absolutePosition.top && hash.absolutePosition.left), 'UI hash includes: absolutePosition');
+ ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
+ ok(hash.item, 'UI hash includes: item');
+ ok(!hash.sender, 'UI hash does not include: sender');
+
+
});
test("sort", function() {
- ok(false, "missing test - untested code is broken code.");
+
+ var hash;
+ $("#sortable")
+ .sortable({ sort: function(e, ui) { hash = ui; } })
+ .find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 });
+
+ ok(hash, 'sort event triggered');
+ ok(hash.helper, 'UI hash includes: helper');
+ ok(hash.placeholder, 'UI hash includes: placeholder');
+ ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
+ ok(hash.absolutePosition && (hash.absolutePosition.top && hash.absolutePosition.left), 'UI hash includes: absolutePosition');
+ ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
+ ok(hash.item, 'UI hash includes: item');
+ ok(!hash.sender, 'UI hash does not include: sender');
+
});
test("change", function() {
- ok(false, "missing test - untested code is broken code.");
+
+ var hash;
+ $("#sortable")
+ .sortable({ change: function(e, ui) { hash = ui; } })
+ .find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 });
+
+ ok(!hash, '1px drag, change event should not be triggered');
+
+ $("#sortable")
+ .sortable({ change: function(e, ui) { hash = ui; } })
+ .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
+
+ ok(hash, 'change event triggered');
+ ok(hash.helper, 'UI hash includes: helper');
+ ok(hash.placeholder, 'UI hash includes: placeholder');
+ ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
+ ok(hash.absolutePosition && (hash.absolutePosition.top && hash.absolutePosition.left), 'UI hash includes: absolutePosition');
+ ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
+ ok(hash.item, 'UI hash includes: item');
+ ok(!hash.sender, 'UI hash does not include: sender');
+
});
test("beforeStop", function() {
- ok(false, "missing test - untested code is broken code.");
+
+ var hash;
+ $("#sortable")
+ .sortable({ beforeStop: function(e, ui) { hash = ui; } })
+ .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
+
+ ok(hash, 'beforeStop event triggered');
+ ok(hash.helper, 'UI hash includes: helper');
+ ok(hash.placeholder, 'UI hash includes: placeholder');
+ ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
+ ok(hash.absolutePosition && (hash.absolutePosition.top && hash.absolutePosition.left), 'UI hash includes: absolutePosition');
+ ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
+ ok(hash.item, 'UI hash includes: item');
+ ok(!hash.sender, 'UI hash does not include: sender');
+
});
test("stop", function() {
- ok(false, "missing test - untested code is broken code.");
+
+ var hash;
+ $("#sortable")
+ .sortable({ stop: function(e, ui) { hash = ui; } })
+ .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
+
+ ok(hash, 'stop event triggered');
+ ok(!hash.helper, 'UI should not include: helper');
+ ok(hash.placeholder, 'UI hash includes: placeholder');
+ ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
+ ok(hash.absolutePosition && (hash.absolutePosition.top && hash.absolutePosition.left), 'UI hash includes: absolutePosition');
+ ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
+ ok(hash.item, 'UI hash includes: item');
+ ok(!hash.sender, 'UI hash does not include: sender');
+
});
test("update", function() {
- ok(false, "missing test - untested code is broken code.");
+
+ var hash;
+ $("#sortable")
+ .sortable({ update: function(e, ui) { hash = ui; } })
+ .find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 });
+
+ ok(!hash, '1px drag, update event should not be triggered');
+
+ $("#sortable")
+ .sortable({ update: function(e, ui) { hash = ui; } })
+ .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
+
+ ok(hash, 'update event triggered');
+ ok(!hash.helper, 'UI hash should not include: helper');
+ ok(hash.placeholder, 'UI hash includes: placeholder');
+ ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
+ ok(hash.absolutePosition && (hash.absolutePosition.top && hash.absolutePosition.left), 'UI hash includes: absolutePosition');
+ ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
+ ok(hash.item, 'UI hash includes: item');
+ ok(!hash.sender, 'UI hash does not include: sender');
+
});
test("receive", function() {