diff options
Diffstat (limited to 'src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable')
8 files changed, 731 insertions, 0 deletions
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/all.html b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/all.html new file mode 100644 index 0000000..0ee6b56 --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Sortable Test Suite</title> + + <script src="../../../jquery-1.7.1.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "sortable" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Sortable Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable.html b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable.html new file mode 100644 index 0000000..a20eb71 --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable.html @@ -0,0 +1,64 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Sortable Test Suite</title> + + <script src="../../jquery.js"></script> + <script src="../../resource_loader.js"></script> + <script> + loadResources({ + css: [ "ui.core", "ui.sortable" ], + js: [ + "ui/jquery.ui.core.js", + "ui/jquery.ui.widget.js", + "ui/jquery.ui.mouse.js", + "ui/jquery.ui.sortable.js" + ] + }); + </script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> + + <script src="sortable_core.js"></script> + <script src="sortable_defaults.js"></script> + <script src="sortable_events.js"></script> + <script src="sortable_methods.js"></script> + <script src="sortable_options.js"></script> + <script src="sortable_tickets.js"></script> + + <script> + // disable this stale testsuite for testswarm only + var url = window.location.search; + url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); + if ( url && url.indexOf("http") == 0 ) { + // reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script + QUnit.init(); + test("sortable", function() { ok(true, "disabled sortable testsuite"); }); + } + </script> + <script src="../swarminject.js"></script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Sortable Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +<ul id="sortable"> + <li>Item 1</li> + <li>Item 2</li> + <li>Item 3</li> + <li>Item 4</li> + <li>Item 5</li> +</ul> + +</div> +</body> +</html> diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_core.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_core.js new file mode 100644 index 0000000..ff18598 --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_core.js @@ -0,0 +1,9 @@ +/* + * sortable_core.js + */ + +(function($) { + +module("sortable: core"); + +})(jQuery); diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_defaults.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_defaults.js new file mode 100644 index 0000000..7681add --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_defaults.js @@ -0,0 +1,34 @@ +/* + * sortable_defaults.js + */ + +var sortable_defaults = { + appendTo: "parent", + axis: false, + cancel: ":input,option", + connectWith: false, + containment: false, + cursor: 'auto', + cursorAt: false, + delay: 0, + disabled: false, + distance: 1, + dropOnEmpty: true, + forcePlaceholderSize: false, + forceHelperSize: false, + grid: false, + handle: false, + helper: "original", + items: "> *", + opacity: false, + placeholder: false, + revert: false, + scroll: true, + scrollSensitivity: 20, + scrollSpeed: 20, + scope: "default", + tolerance: "intersect", + zIndex: 1000 +}; + +commonWidgetTests('sortable', { defaults: sortable_defaults }); diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_events.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_events.js new file mode 100644 index 0000000..cb4ff4f --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_events.js @@ -0,0 +1,147 @@ +/* + * sortable_events.js + */ +(function($) { + +module("sortable: events"); + +test("start", function() { + + 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.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() { + + 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.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() { + + 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.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() { + + 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.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() { + + 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.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() { + + 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.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() { + ok(false, "missing test - untested code is broken code."); +}); + +test("remove", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("over", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("out", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("activate", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("deactivate", function() { + ok(false, "missing test - untested code is broken code."); +}); + +})(jQuery); diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_methods.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_methods.js new file mode 100644 index 0000000..c4b5cdc --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_methods.js @@ -0,0 +1,108 @@ +/* + * sortable_methods.js + */ +(function($) { + +var el, offsetBefore, offsetAfter, dragged; + +var drag = function(handle, dx, dy) { + offsetBefore = $(handle).offset(); + $(handle).simulate("drag", { + dx: dx || 0, + dy: dy || 0 + }); + dragged = { dx: dx, dy: dy }; + offsetAfter = $(handle).offset(); +} + +var sort = function(handle, dx, dy, index, msg) { + drag(handle, dx, dy); + equals($(handle).parent().children().index(handle), index, msg); +} + +module("sortable: methods"); + +test("init", function() { + expect(6); + + $("<div></div>").appendTo('body').sortable().remove(); + ok(true, '.sortable() called on element'); + + $([]).sortable(); + ok(true, '.sortable() called on empty collection'); + + $("<div></div>").sortable(); + ok(true, '.sortable() called on disconnected DOMElement'); + + $("<div></div>").sortable().sortable("foo"); + ok(true, 'arbitrary method called after init'); + + $("<div></div>").sortable().sortable("option", "foo"); + ok(true, 'arbitrary option getter after init'); + + $("<div></div>").sortable().sortable("option", "foo", "bar"); + ok(true, 'arbitrary option setter after init'); +}); + +test("destroy", function() { + $("<div></div>").appendTo('body').sortable().sortable("destroy").remove(); + ok(true, '.sortable("destroy") called on element'); + + $([]).sortable().sortable("destroy"); + ok(true, '.sortable("destroy") called on empty collection'); + + $("<div></div>").sortable().sortable("destroy"); + ok(true, '.sortable("destroy") called on disconnected DOMElement'); + + $("<div></div>").sortable().sortable("destroy").sortable("foo"); + ok(true, 'arbitrary method called after destroy'); + + var expected = $('<div></div>').sortable(), + actual = expected.sortable('destroy'); + equals(actual, expected, 'destroy is chainable'); +}); + +test("enable", function() { + expect(5); + el = $("#sortable").sortable({ disabled: true }); + + sort($("li", el)[0], 0, 40, 0, '.sortable({ disabled: true })'); + + el.sortable("enable"); + equals(el.sortable("option", "disabled"), false, "disabled option getter"); + + el.sortable("destroy"); + el.sortable({ disabled: true }); + el.sortable("option", "disabled", false); + equals(el.sortable("option", "disabled"), false, "disabled option setter"); + + sort($("li", el)[0], 0, 40, 2, '.sortable("option", "disabled", false)'); + + var expected = $('<div></div>').sortable(), + actual = expected.sortable('enable'); + equals(actual, expected, 'enable is chainable'); +}); + +test("disable", function() { + expect(7); + el = $("#sortable").sortable({ disabled: false }); + sort($("li", el)[0], 0, 40, 2, '.sortable({ disabled: false })'); + + el.sortable("disable"); + sort($("li", el)[0], 0, 40, 0, 'disabled.sortable getter'); + + el.sortable("destroy"); + + el.sortable({ disabled: false }); + sort($("li", el)[0], 0, 40, 2, '.sortable({ disabled: false })'); + el.sortable("option", "disabled", true); + equals(el.sortable("option", "disabled"), true, "disabled option setter"); + ok(el.sortable("widget").is(":not(.ui-state-disabled)"), "sortable element does not get ui-state-disabled since it's an interaction"); + sort($("li", el)[0], 0, 40, 0, '.sortable("option", "disabled", true)'); + + var expected = $('<div></div>').sortable(), + actual = expected.sortable('disable'); + equals(actual, expected, 'disable is chainable'); +}); + +})(jQuery); diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_options.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_options.js new file mode 100644 index 0000000..507d5dc --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_options.js @@ -0,0 +1,256 @@ +/* + * sortable_options.js + */ +(function($) { + +module("sortable: options"); + +test("{ appendTo: 'parent' }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ appendTo: Selector }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ axis: false }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ axis: 'x' }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ axis: 'y' }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ axis: ? }, unexpected", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ cancel: ':input,button' }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ cancel: Selector }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ connectWith: false }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ connectWith: Selector }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ containment: false }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ containment: Element }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ containment: 'document' }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ containment: 'parent' }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ containment: 'window' }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ containment: Selector }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ cursor: 'auto' }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ cursor: 'move' }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ cursorAt: false }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ cursorAt: true }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ delay: 0 }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ delay: 100 }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ distance: 1 }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ distance: 10 }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ dropOnEmpty: true }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ dropOnEmpty: false }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ forcePlaceholderSize: false }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ forcePlaceholderSize: true }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ forceHelperSize: false }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ forceHelperSize: true }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ grid: false }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ grid: [17, 3] }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ grid: [3, 7] }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ handle: false }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ handle: Element }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ handle: Selector }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ helper: 'original' }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ helper: Function }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ items: '> *' }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ items: Selector }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ opacity: false }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ opacity: .37 }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ opacity: 1 }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ placeholder: false }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ placeholder: String }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ revert: false }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ revert: true }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ scroll: true }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ scroll: false }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ scrollSensitivity: 20 }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ scrollSensitivity: 2 }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ scrollSensitivity: 200 }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ scrollSpeed: 20 }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ scrollSpeed: 2 }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ scrollSpeed: 200 }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ scope: 'default' }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ scope: ??? }, unexpected", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ tolerance: 'intersect' }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ tolerance: 'pointer' }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ zIndex: 1000 }, default", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ zIndex: 1 }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("{ zIndex: false }", function() { + ok(false, "missing test - untested code is broken code."); +}); + +})(jQuery); diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_tickets.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_tickets.js new file mode 100644 index 0000000..3edc8c0 --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_tickets.js @@ -0,0 +1,83 @@ +/* + * sortable_tickets.js + */ +(function($) { + +var el, offsetBefore, offsetAfter, dragged; + +var drag = function(handle, dx, dy) { + offsetBefore = $(handle).offset(); + $(handle).simulate("drag", { + dx: dx || 0, + dy: dy || 0 + }); + dragged = { dx: dx, dy: dy }; + offsetAfter = $(handle).offset(); +} + +var sort = function(handle, dx, dy, index, msg) { + drag(handle, dx, dy); + equals($(handle).parent().children().index(handle), index, msg); +} + +module("sortable: tickets"); + +test("#3019: Stop fires too early", function() { + + var helper = null; + el = $("#sortable").sortable({ + stop: function(event, ui) { + helper = ui.helper; + } + }); + + sort($("li", el)[0], 0, 40, 2, 'Dragging the sortable'); + equals(helper, null, "helper should be false"); + +}); + +test('#4752: link event firing on sortable with connect list', function () { + var fired = {}, + hasFired = function (type) { return (type in fired) && (true === fired[type]); }; + + $('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable'); + + $('#main ul').sortable({ + connectWith: '#main ul', + change: function (e, ui) { + fired.change = true; + }, + receive: function (e, ui) { + fired.receive = true; + }, + remove: function (e, ui) { + fired.remove = true; + } + }); + + $('#main ul li').live('click.ui-sortable-test', function () { + fired.click = true; + }); + + $('#sortable li:eq(0)').simulate('click'); + ok(!hasFired('change'), 'Click only, change event should not have fired'); + ok(hasFired('click'), 'Click event should have fired'); + + // Drag an item within the first list + fired = {}; + $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 40 }); + ok(hasFired('change'), '40px drag, change event should have fired'); + ok(!hasFired('receive'), 'Receive event should not have fired'); + ok(!hasFired('remove'), 'Remove event should not have fired'); + ok(!hasFired('click'), 'Click event should not have fired'); + + // Drag an item from the first list to the second, connected list + fired = {}; + $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 150 }); + ok(hasFired('change'), '150px drag, change event should have fired'); + ok(hasFired('receive'), 'Receive event should have fired'); + ok(hasFired('remove'), 'Remove event should have fired'); + ok(!hasFired('click'), 'Click event should not have fired'); +}); + +})(jQuery); |