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 --- .../jquery-ui-1.9pre/tests/unit/sortable/all.html | 30 +++ .../tests/unit/sortable/sortable.html | 64 ++++++ .../tests/unit/sortable/sortable_core.js | 9 + .../tests/unit/sortable/sortable_defaults.js | 34 +++ .../tests/unit/sortable/sortable_events.js | 147 ++++++++++++ .../tests/unit/sortable/sortable_methods.js | 108 +++++++++ .../tests/unit/sortable/sortable_options.js | 256 +++++++++++++++++++++ .../tests/unit/sortable/sortable_tickets.js | 83 +++++++ 8 files changed, 731 insertions(+) create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/all.html create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable.html create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_core.js create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_defaults.js create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_events.js create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_methods.js create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_options.js create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable/sortable_tickets.js (limited to 'src/main/webapp/jquery-ui-1.9pre/tests/unit/sortable') 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 @@ + + + + + jQuery UI Sortable Test Suite + + + + + + + + + + + + + +

jQuery UI Sortable Test Suite

+

+
+

+
    +
    + +
    + + 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 @@ + + + + + jQuery UI Sortable Test Suite + + + + + + + + + + + + + + + + + + + + + + +

    jQuery UI Sortable Test Suite

    +

    +
    +

    +
      +
      + + + +
      + + 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); + + $("
      ").appendTo('body').sortable().remove(); + ok(true, '.sortable() called on element'); + + $([]).sortable(); + ok(true, '.sortable() called on empty collection'); + + $("
      ").sortable(); + ok(true, '.sortable() called on disconnected DOMElement'); + + $("
      ").sortable().sortable("foo"); + ok(true, 'arbitrary method called after init'); + + $("
      ").sortable().sortable("option", "foo"); + ok(true, 'arbitrary option getter after init'); + + $("
      ").sortable().sortable("option", "foo", "bar"); + ok(true, 'arbitrary option setter after init'); +}); + +test("destroy", function() { + $("
      ").appendTo('body').sortable().sortable("destroy").remove(); + ok(true, '.sortable("destroy") called on element'); + + $([]).sortable().sortable("destroy"); + ok(true, '.sortable("destroy") called on empty collection'); + + $("
      ").sortable().sortable("destroy"); + ok(true, '.sortable("destroy") called on disconnected DOMElement'); + + $("
      ").sortable().sortable("destroy").sortable("foo"); + ok(true, 'arbitrary method called after destroy'); + + var expected = $('
      ').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 = $('
      ').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 = $('
      ').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); -- cgit v1.1