From bde431bb449b1d957d4e0b736111ff342f2a919d Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 7 Apr 2015 10:55:52 -0400 Subject: Tests: Rename files Ref gh-1528 --- tests/unit/sortable/common.js | 53 +++ tests/unit/sortable/core.js | 42 +++ tests/unit/sortable/events.js | 378 ++++++++++++++++++++ tests/unit/sortable/helper.js | 16 + tests/unit/sortable/methods.js | 129 +++++++ tests/unit/sortable/options.js | 496 +++++++++++++++++++++++++++ tests/unit/sortable/sortable_common.js | 53 --- tests/unit/sortable/sortable_core.js | 42 --- tests/unit/sortable/sortable_events.js | 378 -------------------- tests/unit/sortable/sortable_methods.js | 129 ------- tests/unit/sortable/sortable_options.js | 496 --------------------------- tests/unit/sortable/sortable_test_helpers.js | 16 - 12 files changed, 1114 insertions(+), 1114 deletions(-) create mode 100644 tests/unit/sortable/common.js create mode 100644 tests/unit/sortable/core.js create mode 100644 tests/unit/sortable/events.js create mode 100644 tests/unit/sortable/helper.js create mode 100644 tests/unit/sortable/methods.js create mode 100644 tests/unit/sortable/options.js delete mode 100644 tests/unit/sortable/sortable_common.js delete mode 100644 tests/unit/sortable/sortable_core.js delete mode 100644 tests/unit/sortable/sortable_events.js delete mode 100644 tests/unit/sortable/sortable_methods.js delete mode 100644 tests/unit/sortable/sortable_options.js delete mode 100644 tests/unit/sortable/sortable_test_helpers.js (limited to 'tests/unit/sortable') diff --git a/tests/unit/sortable/common.js b/tests/unit/sortable/common.js new file mode 100644 index 000000000..ab43251ab --- /dev/null +++ b/tests/unit/sortable/common.js @@ -0,0 +1,53 @@ +define( [ + "lib/common", + "ui/sortable" +], function( common ) { + +common.testWidget( "sortable", { + defaults: { + appendTo: "parent", + axis: false, + cancel: "input, textarea, button, select, option", + classes: {}, + 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, + + // callbacks + activate: null, + beforeStop: null, + change: null, + create: null, + deactivate: null, + out: null, + over: null, + receive: null, + remove: null, + sort: null, + start: null, + stop: null, + update: null + } +}); + +} ); diff --git a/tests/unit/sortable/core.js b/tests/unit/sortable/core.js new file mode 100644 index 000000000..7e973ec05 --- /dev/null +++ b/tests/unit/sortable/core.js @@ -0,0 +1,42 @@ +define( [ + "jquery", + "./helper", + "ui/sortable" +], function( $, testHelper ) { + +module( "sortable: core" ); + +test( "#9314: Sortable: Items cannot be dragged directly into bottom position", function() { + expect( 1 ); + + var el = $( ".connectWith" ).sortable({ + connectWith: ".connectWith" + }); + + testHelper.sort( $( "li", el[ 1 ] )[ 0 ], 0, -12, 5, "Dragging the sortable into connected sortable" ); +}); + +test( "ui-sortable-handle applied to appropriate element", function( assert ) { + expect( 8 ); + var item = "
  • ", + el = $( "" ) + .sortable() + .appendTo( "#qunit-fixture" ); + + assert.hasClasses( el.find( "li:first" ), "ui-sortable-handle" ); + assert.hasClasses( el.find( "li:last" ), "ui-sortable-handle" ); + + el.sortable( "option", "handle", "p" ); + assert.lacksClasses( el.find( "li" )[ 0 ], "ui-sortable-handle" ); + assert.lacksClasses( el.find( "li" )[ 1 ], "ui-sortable-handle" ); + assert.hasClasses( el.find( "p" )[ 0 ], "ui-sortable-handle" ); + assert.hasClasses( el.find( "p" )[ 1 ], "ui-sortable-handle" ); + + el.append( item ).sortable( "refresh" ); + assert.hasClasses( el.find( "p:last" ), "ui-sortable-handle" ); + + el.sortable( "destroy" ); + equal( el.find( ".ui-sortable-handle" ).length, 0, "class name removed on destroy" ); +}); + +} ); diff --git a/tests/unit/sortable/events.js b/tests/unit/sortable/events.js new file mode 100644 index 000000000..174da203d --- /dev/null +++ b/tests/unit/sortable/events.js @@ -0,0 +1,378 @@ +define( [ + "jquery", + "./helper", + "ui/sortable", + "ui/draggable" +], function( $, testHelper ) { + +module("sortable: events"); + +test("start", function() { + expect( 7 ); + + var hash; + $("#sortable").sortable({ + start: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dy: 10 + }); + + ok(hash, "start event triggered"); + ok(hash.helper, "UI hash includes: helper"); + ok(hash.placeholder, "UI hash includes: placeholder"); + ok(hash.item, "UI hash includes: item"); + ok(!hash.sender, "UI hash does not include: sender"); + + // todo: see if these events should actually have sane values in them + ok("position" in hash, "UI hash includes: position"); + ok("offset" in hash, "UI hash includes: offset"); +}); + +test("sort", function() { + expect( 7 ); + + var hash; + $("#sortable").sortable({ + sort: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dy: 10 + }); + + ok(hash, "sort event triggered"); + ok(hash.helper, "UI hash includes: helper"); + ok(hash.placeholder, "UI hash includes: placeholder"); + ok(hash.position && ("top" in hash.position && "left" in hash.position), "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() { + expect( 8 ); + + 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", { + dy: 22 + }); + + ok(hash, "change event triggered"); + ok(hash.helper, "UI hash includes: helper"); + ok(hash.placeholder, "UI hash includes: placeholder"); + ok(hash.position && ("top" in hash.position && "left" in hash.position), "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() { + expect( 7 ); + + var hash; + $("#sortable").sortable({ + beforeStop: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dy: 20 + }); + + ok(hash, "beforeStop event triggered"); + ok(hash.helper, "UI hash includes: helper"); + ok(hash.placeholder, "UI hash includes: placeholder"); + ok(hash.position && ("top" in hash.position && "left" in hash.position), "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() { + expect( 7 ); + + var hash; + $("#sortable").sortable({ + stop: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + 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 && ("top" in hash.position && "left" in hash.position), "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() { + expect( 8 ); + + 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", { + dy: 22 + }); + + ok(hash, "update event triggered"); + ok(!hash.helper, "UI hash should not include: helper"); + ok(hash.placeholder, "UI hash includes: placeholder"); + ok(hash.position && ("top" in hash.position && "left" in hash.position), "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("#3019: Stop fires too early", function() { + expect(2); + + var helper = null, + el = $("#sortable").sortable({ + stop: function(event, ui) { + helper = ui.helper; + } + }); + + testHelper.sort($("li", el)[0], 0, 44, 2, "Dragging the sortable"); + equal(helper, null, "helper should be false"); + +}); + +test("#4752: link event firing on sortable with connect list", function () { + expect( 10 ); + + var fired = {}, + hasFired = function (type) { return (type in fired) && (true === fired[type]); }; + + $("#sortable").clone().attr("id", "sortable2").insertAfter("#sortable"); + + $("#qunit-fixture ul").sortable({ + connectWith: "#qunit-fixture ul", + change: function () { + fired.change = true; + }, + receive: function () { + fired.receive = true; + }, + remove: function () { + fired.remove = true; + } + }); + + $("#qunit-fixture ul").bind("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"); +}); + +/* +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() { + expect( 8 ); + + var hash, + overCount = 0; + + $( "#sortable" ).sortable({ + over: function( e, ui ) { + hash = ui; + overCount++; + } + }).find( "li:eq(0)" ).simulate( "drag", { + dy: 20 + }); + + ok( hash, "over event triggered" ); + ok( hash.helper, "UI includes: helper" ); + ok( hash.placeholder, "UI hash includes: placeholder" ); + ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "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 includes: sender" ); + equal( overCount, 1, "over fires only once" ); +}); + +// http://bugs.jqueryui.com/ticket/9335 +// Sortable: over & out events does not consistently fire +test( "over, fires with draggable connected to sortable", function() { + expect( 3 ); + + var hash, + overCount = 0, + item = $( "
    " ).text( "6" ).insertAfter( "#sortable" ); + + item.draggable({ + connectToSortable: "#sortable" + }); + $( ".connectWith" ).sortable({ + connectWith: ".connectWith", + over: function( event, ui ) { + hash = ui; + overCount++; + } + }); + + item.simulate( "drag", { + dy: -20 + }); + + ok( hash, "over event triggered" ); + ok( !hash.sender, "UI should not include: sender" ); + equal( overCount, 1, "over fires only once" ); +}); + +test( "over, with connected sortable", function() { + expect( 3 ); + + var hash, + overCount = 0; + + $( ".connectWith" ).sortable({ + connectWith: ".connectWith" + }); + $( "#sortable2" ).on( "sortover", function( event, ui ) { + hash = ui; + overCount++; + }); + $( "#sortable" ).find( "li:eq(0)" ).simulate( "drag", { + dy: 102 + }); + + ok( hash, "over event triggered" ); + equal( hash.sender[ 0 ], $(" #sortable" )[ 0 ], "UI includes: sender" ); + equal( overCount, 1, "over fires only once" ); +}); + +/* +test("out", function() { + ok(false, "missing test - untested code is broken code."); +}); +*/ + +test( "out, with connected sortable", function() { + expect( 2 ); + + var hash, + outCount = 0; + + $( ".connectWith" ).sortable({ + connectWith: ".connectWith" + }); + $( "#sortable" ).on( "sortout", function( event, ui ) { + hash = ui; + outCount++; + }); + $( "#sortable" ).find( "li:last" ).simulate( "drag", { + dy: 40 + }); + + ok( hash, "out event triggered" ); + equal( outCount, 1, "out fires only once" ); +}); + +test( "repeated out & over between connected sortables", function() { + expect( 2 ); + + var outCount = 0, + overCount = 0; + + $( ".connectWith" ).sortable({ + connectWith: ".connectWith", + over: function() { + overCount++; + }, + out: function( event, ui ) { + // Ignore events that trigger when an item has dropped + // checking for the presence of the helper. + if ( !ui.helper ) { + outCount++; + } + } + }); + $( "#sortable" ).find( "li:last" ).simulate( "drag", { + dy: 40 + }).simulate( "drag", { + dy: -40 + }); + + equal( outCount, 2, "out fires twice" ); + equal( overCount, 4, "over fires four times" ); +}); + +/* +test("activate", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("deactivate", function() { + ok(false, "missing test - untested code is broken code."); +}); +*/ + +} ); diff --git a/tests/unit/sortable/helper.js b/tests/unit/sortable/helper.js new file mode 100644 index 000000000..76545022e --- /dev/null +++ b/tests/unit/sortable/helper.js @@ -0,0 +1,16 @@ +define( [ + "jquery", + "lib/helper" +], function( $, helper ) { + +return $.extend( helper, { + sort: function( handle, dx, dy, index, msg ) { + $( handle ).simulate( "drag", { + dx: dx, + dy: dy + }); + equal( $( handle ).parent().children().index( handle ), index, msg ); + } +} ); + +} ); diff --git a/tests/unit/sortable/methods.js b/tests/unit/sortable/methods.js new file mode 100644 index 000000000..d88b8089f --- /dev/null +++ b/tests/unit/sortable/methods.js @@ -0,0 +1,129 @@ +define( [ + "jquery", + "./helper", + "ui/sortable" +], function( $, testHelper ) { + +module("sortable: methods"); + +test("init", function() { + expect(5); + + $("
    ").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("option", "foo"); + ok(true, "arbitrary option getter after init"); + + $("
    ").sortable().sortable("option", "foo", "bar"); + ok(true, "arbitrary option setter after init"); +}); + +test("destroy", function() { + expect(4); + $("
    ").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"); + + var expected = $("
    ").sortable(), + actual = expected.sortable("destroy"); + equal(actual, expected, "destroy is chainable"); +}); + +test("enable", function() { + expect(5); + + var el, actual, expected; + + el = $("#sortable").sortable({ disabled: true }); + + testHelper.sort($("li", el)[0], 0, 44, 0, ".sortable({ disabled: true })"); + + el.sortable("enable"); + equal(el.sortable("option", "disabled"), false, "disabled option getter"); + + el.sortable("destroy"); + el.sortable({ disabled: true }); + el.sortable("option", "disabled", false); + equal(el.sortable("option", "disabled"), false, "disabled option setter"); + + testHelper.sort($("li", el)[0], 0, 44, 2, ".sortable('option', 'disabled', false)"); + + expected = $("
    ").sortable(), + actual = expected.sortable("enable"); + equal(actual, expected, "enable is chainable"); +}); + +test( "disable", function( assert ) { + expect( 9 ); + + var chainable, + element = $( "#sortable" ).sortable({ disabled: false }); + + testHelper.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); + + chainable = element.sortable( "disable" ); + testHelper.sort( $( "li", element )[ 0 ], 0, 44, 0, "disabled.sortable getter" ); + + element.sortable( "destroy" ); + + element.sortable({ disabled: false }); + testHelper.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); + element.sortable( "option", "disabled", true); + equal( element.sortable( "option", "disabled" ), true, "disabled option setter" ); + + assert.lacksClasses( element.sortable( "widget" ), "ui-state-disabled" ); + ok( !element.sortable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + assert.hasClasses( element.sortable( "widget" ), "ui-sortable-disabled" ); + + testHelper.sort($( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" ); + equal( chainable, element, "disable is chainable" ); +}); + +test( "refresh() should update the positions of initially empty lists (see #7498)", function() { + expect( 1 ); + + var changeCount = 0, + element = $( "#qunit-fixture" ).html( "" ).find( "ul" ); + + element + .css({ + "float": "left", + width: "100px" + }) + .sortable({ + change: function() { + changeCount++; + } + }) + .append( "
  • a
  • a
  • " ) + .find( "li" ) + .css({ + "float": "left", + width: "50px", + height: "50px" + }); + + element.sortable( "refresh" ); + + // Switch the order of the two li elements + element.find( "li" ).eq( 0 ).simulate( "drag", { + dx: 55, + moves: 15 + }); + + equal( changeCount, 1 ); +}); + +} ); diff --git a/tests/unit/sortable/options.js b/tests/unit/sortable/options.js new file mode 100644 index 000000000..930f339e6 --- /dev/null +++ b/tests/unit/sortable/options.js @@ -0,0 +1,496 @@ +define( [ + "jquery", + "ui/sortable" +], 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() { + expect( 2 ); + + var offsetAfter, + element = $( "#sortable" ).sortable({ + axis: false, + change: function() { + offsetAfter = item.offset(); + notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: false" ); + notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: false" ); + } + }), + item = element.find( "li" ).eq( 0 ), + offsetBefore = item.offset(); + + item.simulate( "drag", { + dx: 50, + dy: 25, + moves: 1 + }); +}); + +test( "{ axis: 'x' }", function() { + expect( 2 ); + + var offsetAfter, + element = $( "#sortable" ).sortable({ + axis: "x", + change: function() { + offsetAfter = item.offset(); + notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: x" ); + equal( offsetAfter.top, offsetBefore.top, "y axis constrained when axis: x" ); + } + }), + item = element.find( "li" ).eq( 0 ), + offsetBefore = item.offset(); + + item.simulate( "drag", { + dx: 50, + dy: 25, + moves: 1 + }); +}); + +test( "{ axis: 'y' }", function() { + expect( 2 ); + + var offsetAfter, + element = $( "#sortable" ).sortable({ + axis: "y", + change: function() { + offsetAfter = item.offset(); + equal( offsetAfter.left, offsetBefore.left, "x axis constrained when axis: y" ); + notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: y" ); + } + }), + item = element.find( "li" ).eq( 0 ), + offsetBefore = item.offset(); + + item.simulate( "drag", { + dx: 50, + dy: 25, + moves: 1 + }); +}); + +asyncTest( "#7415: Incorrect revert animation with axis: 'y'", function() { + expect( 2 ); + var expectedLeft, + element = $( "#sortable" ).sortable({ + axis: "y", + revert: true, + stop: start, + sort: function() { + expectedLeft = item.css( "left" ); + } + }), + item = element.find( "li" ).eq( 0 ); + + item.simulate( "drag", { + dy: 300, + dx: 50 + }); + + setTimeout(function() { + var top = parseFloat( item.css( "top" ) ); + equal( item.css( "left" ), expectedLeft, "left not animated" ); + ok( top > 0 && top < 300, "top is animated" ); + }, 100 ); +}); + +/* +test("{ cancel: 'input,textarea,button,select,option' }, 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( "#8792: issues with floated items in connected lists", function() { + expect( 2 ); + + var element, + changeCount = 0; + + $( "#qunit-fixture" ) + .html( "" ) + .find( "ul" ).css({ "float": "left", width: "100px" }).end() + .find( "li" ).css({ "float": "left", width: "50px", height: "50px" }); + + $( "#qunit-fixture .c" ).sortable({ + connectWith: "#qunit-fixture .c", + change: function() { + changeCount++; + } + }); + + element = $( "#qunit-fixture li:eq(0)" ); + + // move the first li to the right of the second li in the first ul + element.simulate( "drag", { + dx: 55, + moves: 15 + }); + + equal( changeCount, 1, "change fired only once (no jitters) when dragging a floated sortable in it's own container" ); + + // move the first li ( which is now in the second spot ) + // through the first spot in the second ul to the second spot in the second ul + element.simulate( "drag", { + dx: 100, + moves: 15 + }); + + equal( changeCount, 3, "change fired once for each expected change when dragging a floated sortable to a connected container" ); +}); + +test( "#8301: single axis with connected list", function() { + expect( 1 ); + + var element = $( "#sortable" ).sortable({ + axis: "y", + tolerance: "pointer", + connectWith: ".connected" + }); + + $( "" ) + .sortable({ + axis: "y", + tolerance: "pointer", + connectWith: "#sortable", + receive: function() { + ok( true, "connected list received item" ); + } + }) + .insertAfter( element ); + + element.find( "li" ).eq( 0 ).simulate( "drag", { + handle: "corner", + dy: 120, + moves: 1 + }); +}); + +/* +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: false } img", function() { + expect( 3 ); + + var element = $( "#sortable-images" ).sortable({ + start: function( event, ui ) { + ok( ui.placeholder.attr( "src" ).indexOf( "images/jqueryui_32x32.png" ) > 0, "placeholder img has correct src" ); + equal( ui.placeholder.height(), 32, "placeholder has correct height" ); + equal( ui.placeholder.width(), 32, "placeholder has correct width" ); + } + }); + + element.find( "img" ).eq( 0 ).simulate( "drag", { + dy: 1 + }); +}); + +test( "{ placeholder: String }", function( assert ) { + expect( 1 ); + + var element = $( "#sortable" ).sortable({ + placeholder: "test", + start: function( event, ui ) { + assert.hasClasses( ui.placeholder, "test" ); + } + }); + + element.find( "li" ).eq( 0 ).simulate( "drag", { + dy: 1 + }); +}); + +test( "{ placholder: String } tr", function( assert ) { + expect( 4 ); + + var originalWidths, + element = $( "#sortable-table tbody" ).sortable({ + placeholder: "test", + start: function( event, ui ) { + var currentWidths = otherRow.children().map(function() { + return $( this ).width(); + }).get(); + assert.hasClasses( ui.placeholder, "test" ); + deepEqual( currentWidths, originalWidths, "table cells maintian size" ); + equal( ui.placeholder.children().length, dragRow.children().length, + "placeholder has correct number of cells" ); + equal( ui.placeholder.children().html(), $( " " ).html(), + "placeholder td has content for forced dimensions" ); + } + }), + rows = element.children( "tr" ), + dragRow = rows.eq( 0 ), + otherRow = rows.eq( 1 ); + + originalWidths = otherRow.children().map(function() { + return $( this ).width(); + }).get(); + dragRow.simulate( "drag", { + dy: 1 + }); +}); + +test( "{ placholder: String } tbody", function() { + expect( 6 ); + + var originalWidths, + element = $( "#sortable-table" ).sortable({ + placeholder: "test", + start: function( event, ui ) { + var currentWidths = otherBody.children().map(function() { + return $( this ).width(); + }).get(); + ok( ui.placeholder.hasClass( "test" ), "placeholder has class" ); + deepEqual( currentWidths, originalWidths, "table cells maintain size" ); + equal( ui.placeholder.children().length, 1, + "placeholder has one child" ); + equal( ui.placeholder.children( "tr" ).length, 1, + "placeholder's child is tr" ); + equal( ui.placeholder.find( "> tr" ).children().length, + dragBody.find( "> tr:first" ).children().length, + "placeholder's tr has correct number of cells" ); + equal( ui.placeholder.find( "> tr" ).children().html(), + $( " " ).html(), + "placeholder td has content for forced dimensions" ); + } + }), + bodies = element.children( "tbody" ), + dragBody = bodies.eq( 0 ), + otherBody = bodies.eq( 1 ); + + originalWidths = otherBody.children().map(function() { + return $( this ).width(); + }).get(); + dragBody.simulate( "drag", { + dy: 1 + }); +}); + +/* +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."); +}); +*/ +} ); diff --git a/tests/unit/sortable/sortable_common.js b/tests/unit/sortable/sortable_common.js deleted file mode 100644 index ab43251ab..000000000 --- a/tests/unit/sortable/sortable_common.js +++ /dev/null @@ -1,53 +0,0 @@ -define( [ - "lib/common", - "ui/sortable" -], function( common ) { - -common.testWidget( "sortable", { - defaults: { - appendTo: "parent", - axis: false, - cancel: "input, textarea, button, select, option", - classes: {}, - 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, - - // callbacks - activate: null, - beforeStop: null, - change: null, - create: null, - deactivate: null, - out: null, - over: null, - receive: null, - remove: null, - sort: null, - start: null, - stop: null, - update: null - } -}); - -} ); diff --git a/tests/unit/sortable/sortable_core.js b/tests/unit/sortable/sortable_core.js deleted file mode 100644 index 64bdb661e..000000000 --- a/tests/unit/sortable/sortable_core.js +++ /dev/null @@ -1,42 +0,0 @@ -define( [ - "jquery", - "./sortable_test_helpers", - "ui/sortable" -], function( $, testHelper ) { - -module( "sortable: core" ); - -test( "#9314: Sortable: Items cannot be dragged directly into bottom position", function() { - expect( 1 ); - - var el = $( ".connectWith" ).sortable({ - connectWith: ".connectWith" - }); - - testHelper.sort( $( "li", el[ 1 ] )[ 0 ], 0, -12, 5, "Dragging the sortable into connected sortable" ); -}); - -test( "ui-sortable-handle applied to appropriate element", function( assert ) { - expect( 8 ); - var item = "
  • ", - el = $( "" ) - .sortable() - .appendTo( "#qunit-fixture" ); - - assert.hasClasses( el.find( "li:first" ), "ui-sortable-handle" ); - assert.hasClasses( el.find( "li:last" ), "ui-sortable-handle" ); - - el.sortable( "option", "handle", "p" ); - assert.lacksClasses( el.find( "li" )[ 0 ], "ui-sortable-handle" ); - assert.lacksClasses( el.find( "li" )[ 1 ], "ui-sortable-handle" ); - assert.hasClasses( el.find( "p" )[ 0 ], "ui-sortable-handle" ); - assert.hasClasses( el.find( "p" )[ 1 ], "ui-sortable-handle" ); - - el.append( item ).sortable( "refresh" ); - assert.hasClasses( el.find( "p:last" ), "ui-sortable-handle" ); - - el.sortable( "destroy" ); - equal( el.find( ".ui-sortable-handle" ).length, 0, "class name removed on destroy" ); -}); - -} ); diff --git a/tests/unit/sortable/sortable_events.js b/tests/unit/sortable/sortable_events.js deleted file mode 100644 index 453b8b7b6..000000000 --- a/tests/unit/sortable/sortable_events.js +++ /dev/null @@ -1,378 +0,0 @@ -define( [ - "jquery", - "./sortable_test_helpers", - "ui/sortable", - "ui/draggable" -], function( $, testHelper ) { - -module("sortable: events"); - -test("start", function() { - expect( 7 ); - - var hash; - $("#sortable").sortable({ - start: function( e, ui ) { - hash = ui; - } - }).find("li:eq(0)").simulate( "drag", { - dy: 10 - }); - - ok(hash, "start event triggered"); - ok(hash.helper, "UI hash includes: helper"); - ok(hash.placeholder, "UI hash includes: placeholder"); - ok(hash.item, "UI hash includes: item"); - ok(!hash.sender, "UI hash does not include: sender"); - - // todo: see if these events should actually have sane values in them - ok("position" in hash, "UI hash includes: position"); - ok("offset" in hash, "UI hash includes: offset"); -}); - -test("sort", function() { - expect( 7 ); - - var hash; - $("#sortable").sortable({ - sort: function( e, ui ) { - hash = ui; - } - }).find("li:eq(0)").simulate( "drag", { - dy: 10 - }); - - ok(hash, "sort event triggered"); - ok(hash.helper, "UI hash includes: helper"); - ok(hash.placeholder, "UI hash includes: placeholder"); - ok(hash.position && ("top" in hash.position && "left" in hash.position), "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() { - expect( 8 ); - - 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", { - dy: 22 - }); - - ok(hash, "change event triggered"); - ok(hash.helper, "UI hash includes: helper"); - ok(hash.placeholder, "UI hash includes: placeholder"); - ok(hash.position && ("top" in hash.position && "left" in hash.position), "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() { - expect( 7 ); - - var hash; - $("#sortable").sortable({ - beforeStop: function( e, ui ) { - hash = ui; - } - }).find("li:eq(0)").simulate( "drag", { - dy: 20 - }); - - ok(hash, "beforeStop event triggered"); - ok(hash.helper, "UI hash includes: helper"); - ok(hash.placeholder, "UI hash includes: placeholder"); - ok(hash.position && ("top" in hash.position && "left" in hash.position), "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() { - expect( 7 ); - - var hash; - $("#sortable").sortable({ - stop: function( e, ui ) { - hash = ui; - } - }).find("li:eq(0)").simulate( "drag", { - 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 && ("top" in hash.position && "left" in hash.position), "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() { - expect( 8 ); - - 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", { - dy: 22 - }); - - ok(hash, "update event triggered"); - ok(!hash.helper, "UI hash should not include: helper"); - ok(hash.placeholder, "UI hash includes: placeholder"); - ok(hash.position && ("top" in hash.position && "left" in hash.position), "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("#3019: Stop fires too early", function() { - expect(2); - - var helper = null, - el = $("#sortable").sortable({ - stop: function(event, ui) { - helper = ui.helper; - } - }); - - testHelper.sort($("li", el)[0], 0, 44, 2, "Dragging the sortable"); - equal(helper, null, "helper should be false"); - -}); - -test("#4752: link event firing on sortable with connect list", function () { - expect( 10 ); - - var fired = {}, - hasFired = function (type) { return (type in fired) && (true === fired[type]); }; - - $("#sortable").clone().attr("id", "sortable2").insertAfter("#sortable"); - - $("#qunit-fixture ul").sortable({ - connectWith: "#qunit-fixture ul", - change: function () { - fired.change = true; - }, - receive: function () { - fired.receive = true; - }, - remove: function () { - fired.remove = true; - } - }); - - $("#qunit-fixture ul").bind("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"); -}); - -/* -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() { - expect( 8 ); - - var hash, - overCount = 0; - - $( "#sortable" ).sortable({ - over: function( e, ui ) { - hash = ui; - overCount++; - } - }).find( "li:eq(0)" ).simulate( "drag", { - dy: 20 - }); - - ok( hash, "over event triggered" ); - ok( hash.helper, "UI includes: helper" ); - ok( hash.placeholder, "UI hash includes: placeholder" ); - ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "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 includes: sender" ); - equal( overCount, 1, "over fires only once" ); -}); - -// http://bugs.jqueryui.com/ticket/9335 -// Sortable: over & out events does not consistently fire -test( "over, fires with draggable connected to sortable", function() { - expect( 3 ); - - var hash, - overCount = 0, - item = $( "
    " ).text( "6" ).insertAfter( "#sortable" ); - - item.draggable({ - connectToSortable: "#sortable" - }); - $( ".connectWith" ).sortable({ - connectWith: ".connectWith", - over: function( event, ui ) { - hash = ui; - overCount++; - } - }); - - item.simulate( "drag", { - dy: -20 - }); - - ok( hash, "over event triggered" ); - ok( !hash.sender, "UI should not include: sender" ); - equal( overCount, 1, "over fires only once" ); -}); - -test( "over, with connected sortable", function() { - expect( 3 ); - - var hash, - overCount = 0; - - $( ".connectWith" ).sortable({ - connectWith: ".connectWith" - }); - $( "#sortable2" ).on( "sortover", function( event, ui ) { - hash = ui; - overCount++; - }); - $( "#sortable" ).find( "li:eq(0)" ).simulate( "drag", { - dy: 102 - }); - - ok( hash, "over event triggered" ); - equal( hash.sender[ 0 ], $(" #sortable" )[ 0 ], "UI includes: sender" ); - equal( overCount, 1, "over fires only once" ); -}); - -/* -test("out", function() { - ok(false, "missing test - untested code is broken code."); -}); -*/ - -test( "out, with connected sortable", function() { - expect( 2 ); - - var hash, - outCount = 0; - - $( ".connectWith" ).sortable({ - connectWith: ".connectWith" - }); - $( "#sortable" ).on( "sortout", function( event, ui ) { - hash = ui; - outCount++; - }); - $( "#sortable" ).find( "li:last" ).simulate( "drag", { - dy: 40 - }); - - ok( hash, "out event triggered" ); - equal( outCount, 1, "out fires only once" ); -}); - -test( "repeated out & over between connected sortables", function() { - expect( 2 ); - - var outCount = 0, - overCount = 0; - - $( ".connectWith" ).sortable({ - connectWith: ".connectWith", - over: function() { - overCount++; - }, - out: function( event, ui ) { - // Ignore events that trigger when an item has dropped - // checking for the presence of the helper. - if ( !ui.helper ) { - outCount++; - } - } - }); - $( "#sortable" ).find( "li:last" ).simulate( "drag", { - dy: 40 - }).simulate( "drag", { - dy: -40 - }); - - equal( outCount, 2, "out fires twice" ); - equal( overCount, 4, "over fires four times" ); -}); - -/* -test("activate", function() { - ok(false, "missing test - untested code is broken code."); -}); - -test("deactivate", function() { - ok(false, "missing test - untested code is broken code."); -}); -*/ - -} ); diff --git a/tests/unit/sortable/sortable_methods.js b/tests/unit/sortable/sortable_methods.js deleted file mode 100644 index d3bb23d6e..000000000 --- a/tests/unit/sortable/sortable_methods.js +++ /dev/null @@ -1,129 +0,0 @@ -define( [ - "jquery", - "./sortable_test_helpers", - "ui/sortable" -], function( $, testHelper ) { - -module("sortable: methods"); - -test("init", function() { - expect(5); - - $("
    ").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("option", "foo"); - ok(true, "arbitrary option getter after init"); - - $("
    ").sortable().sortable("option", "foo", "bar"); - ok(true, "arbitrary option setter after init"); -}); - -test("destroy", function() { - expect(4); - $("
    ").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"); - - var expected = $("
    ").sortable(), - actual = expected.sortable("destroy"); - equal(actual, expected, "destroy is chainable"); -}); - -test("enable", function() { - expect(5); - - var el, actual, expected; - - el = $("#sortable").sortable({ disabled: true }); - - testHelper.sort($("li", el)[0], 0, 44, 0, ".sortable({ disabled: true })"); - - el.sortable("enable"); - equal(el.sortable("option", "disabled"), false, "disabled option getter"); - - el.sortable("destroy"); - el.sortable({ disabled: true }); - el.sortable("option", "disabled", false); - equal(el.sortable("option", "disabled"), false, "disabled option setter"); - - testHelper.sort($("li", el)[0], 0, 44, 2, ".sortable('option', 'disabled', false)"); - - expected = $("
    ").sortable(), - actual = expected.sortable("enable"); - equal(actual, expected, "enable is chainable"); -}); - -test( "disable", function( assert ) { - expect( 9 ); - - var chainable, - element = $( "#sortable" ).sortable({ disabled: false }); - - testHelper.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); - - chainable = element.sortable( "disable" ); - testHelper.sort( $( "li", element )[ 0 ], 0, 44, 0, "disabled.sortable getter" ); - - element.sortable( "destroy" ); - - element.sortable({ disabled: false }); - testHelper.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); - element.sortable( "option", "disabled", true); - equal( element.sortable( "option", "disabled" ), true, "disabled option setter" ); - - assert.lacksClasses( element.sortable( "widget" ), "ui-state-disabled" ); - ok( !element.sortable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); - assert.hasClasses( element.sortable( "widget" ), "ui-sortable-disabled" ); - - testHelper.sort($( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" ); - equal( chainable, element, "disable is chainable" ); -}); - -test( "refresh() should update the positions of initially empty lists (see #7498)", function() { - expect( 1 ); - - var changeCount = 0, - element = $( "#qunit-fixture" ).html( "" ).find( "ul" ); - - element - .css({ - "float": "left", - width: "100px" - }) - .sortable({ - change: function() { - changeCount++; - } - }) - .append( "
  • a
  • a
  • " ) - .find( "li" ) - .css({ - "float": "left", - width: "50px", - height: "50px" - }); - - element.sortable( "refresh" ); - - // Switch the order of the two li elements - element.find( "li" ).eq( 0 ).simulate( "drag", { - dx: 55, - moves: 15 - }); - - equal( changeCount, 1 ); -}); - -} ); diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js deleted file mode 100644 index 930f339e6..000000000 --- a/tests/unit/sortable/sortable_options.js +++ /dev/null @@ -1,496 +0,0 @@ -define( [ - "jquery", - "ui/sortable" -], 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() { - expect( 2 ); - - var offsetAfter, - element = $( "#sortable" ).sortable({ - axis: false, - change: function() { - offsetAfter = item.offset(); - notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: false" ); - notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: false" ); - } - }), - item = element.find( "li" ).eq( 0 ), - offsetBefore = item.offset(); - - item.simulate( "drag", { - dx: 50, - dy: 25, - moves: 1 - }); -}); - -test( "{ axis: 'x' }", function() { - expect( 2 ); - - var offsetAfter, - element = $( "#sortable" ).sortable({ - axis: "x", - change: function() { - offsetAfter = item.offset(); - notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: x" ); - equal( offsetAfter.top, offsetBefore.top, "y axis constrained when axis: x" ); - } - }), - item = element.find( "li" ).eq( 0 ), - offsetBefore = item.offset(); - - item.simulate( "drag", { - dx: 50, - dy: 25, - moves: 1 - }); -}); - -test( "{ axis: 'y' }", function() { - expect( 2 ); - - var offsetAfter, - element = $( "#sortable" ).sortable({ - axis: "y", - change: function() { - offsetAfter = item.offset(); - equal( offsetAfter.left, offsetBefore.left, "x axis constrained when axis: y" ); - notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: y" ); - } - }), - item = element.find( "li" ).eq( 0 ), - offsetBefore = item.offset(); - - item.simulate( "drag", { - dx: 50, - dy: 25, - moves: 1 - }); -}); - -asyncTest( "#7415: Incorrect revert animation with axis: 'y'", function() { - expect( 2 ); - var expectedLeft, - element = $( "#sortable" ).sortable({ - axis: "y", - revert: true, - stop: start, - sort: function() { - expectedLeft = item.css( "left" ); - } - }), - item = element.find( "li" ).eq( 0 ); - - item.simulate( "drag", { - dy: 300, - dx: 50 - }); - - setTimeout(function() { - var top = parseFloat( item.css( "top" ) ); - equal( item.css( "left" ), expectedLeft, "left not animated" ); - ok( top > 0 && top < 300, "top is animated" ); - }, 100 ); -}); - -/* -test("{ cancel: 'input,textarea,button,select,option' }, 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( "#8792: issues with floated items in connected lists", function() { - expect( 2 ); - - var element, - changeCount = 0; - - $( "#qunit-fixture" ) - .html( "" ) - .find( "ul" ).css({ "float": "left", width: "100px" }).end() - .find( "li" ).css({ "float": "left", width: "50px", height: "50px" }); - - $( "#qunit-fixture .c" ).sortable({ - connectWith: "#qunit-fixture .c", - change: function() { - changeCount++; - } - }); - - element = $( "#qunit-fixture li:eq(0)" ); - - // move the first li to the right of the second li in the first ul - element.simulate( "drag", { - dx: 55, - moves: 15 - }); - - equal( changeCount, 1, "change fired only once (no jitters) when dragging a floated sortable in it's own container" ); - - // move the first li ( which is now in the second spot ) - // through the first spot in the second ul to the second spot in the second ul - element.simulate( "drag", { - dx: 100, - moves: 15 - }); - - equal( changeCount, 3, "change fired once for each expected change when dragging a floated sortable to a connected container" ); -}); - -test( "#8301: single axis with connected list", function() { - expect( 1 ); - - var element = $( "#sortable" ).sortable({ - axis: "y", - tolerance: "pointer", - connectWith: ".connected" - }); - - $( "" ) - .sortable({ - axis: "y", - tolerance: "pointer", - connectWith: "#sortable", - receive: function() { - ok( true, "connected list received item" ); - } - }) - .insertAfter( element ); - - element.find( "li" ).eq( 0 ).simulate( "drag", { - handle: "corner", - dy: 120, - moves: 1 - }); -}); - -/* -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: false } img", function() { - expect( 3 ); - - var element = $( "#sortable-images" ).sortable({ - start: function( event, ui ) { - ok( ui.placeholder.attr( "src" ).indexOf( "images/jqueryui_32x32.png" ) > 0, "placeholder img has correct src" ); - equal( ui.placeholder.height(), 32, "placeholder has correct height" ); - equal( ui.placeholder.width(), 32, "placeholder has correct width" ); - } - }); - - element.find( "img" ).eq( 0 ).simulate( "drag", { - dy: 1 - }); -}); - -test( "{ placeholder: String }", function( assert ) { - expect( 1 ); - - var element = $( "#sortable" ).sortable({ - placeholder: "test", - start: function( event, ui ) { - assert.hasClasses( ui.placeholder, "test" ); - } - }); - - element.find( "li" ).eq( 0 ).simulate( "drag", { - dy: 1 - }); -}); - -test( "{ placholder: String } tr", function( assert ) { - expect( 4 ); - - var originalWidths, - element = $( "#sortable-table tbody" ).sortable({ - placeholder: "test", - start: function( event, ui ) { - var currentWidths = otherRow.children().map(function() { - return $( this ).width(); - }).get(); - assert.hasClasses( ui.placeholder, "test" ); - deepEqual( currentWidths, originalWidths, "table cells maintian size" ); - equal( ui.placeholder.children().length, dragRow.children().length, - "placeholder has correct number of cells" ); - equal( ui.placeholder.children().html(), $( " " ).html(), - "placeholder td has content for forced dimensions" ); - } - }), - rows = element.children( "tr" ), - dragRow = rows.eq( 0 ), - otherRow = rows.eq( 1 ); - - originalWidths = otherRow.children().map(function() { - return $( this ).width(); - }).get(); - dragRow.simulate( "drag", { - dy: 1 - }); -}); - -test( "{ placholder: String } tbody", function() { - expect( 6 ); - - var originalWidths, - element = $( "#sortable-table" ).sortable({ - placeholder: "test", - start: function( event, ui ) { - var currentWidths = otherBody.children().map(function() { - return $( this ).width(); - }).get(); - ok( ui.placeholder.hasClass( "test" ), "placeholder has class" ); - deepEqual( currentWidths, originalWidths, "table cells maintain size" ); - equal( ui.placeholder.children().length, 1, - "placeholder has one child" ); - equal( ui.placeholder.children( "tr" ).length, 1, - "placeholder's child is tr" ); - equal( ui.placeholder.find( "> tr" ).children().length, - dragBody.find( "> tr:first" ).children().length, - "placeholder's tr has correct number of cells" ); - equal( ui.placeholder.find( "> tr" ).children().html(), - $( " " ).html(), - "placeholder td has content for forced dimensions" ); - } - }), - bodies = element.children( "tbody" ), - dragBody = bodies.eq( 0 ), - otherBody = bodies.eq( 1 ); - - originalWidths = otherBody.children().map(function() { - return $( this ).width(); - }).get(); - dragBody.simulate( "drag", { - dy: 1 - }); -}); - -/* -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."); -}); -*/ -} ); diff --git a/tests/unit/sortable/sortable_test_helpers.js b/tests/unit/sortable/sortable_test_helpers.js deleted file mode 100644 index 76545022e..000000000 --- a/tests/unit/sortable/sortable_test_helpers.js +++ /dev/null @@ -1,16 +0,0 @@ -define( [ - "jquery", - "lib/helper" -], function( $, helper ) { - -return $.extend( helper, { - sort: function( handle, dx, dy, index, msg ) { - $( handle ).simulate( "drag", { - dx: dx, - dy: dy - }); - equal( $( handle ).parent().children().index( handle ), index, msg ); - } -} ); - -} ); -- cgit v1.2.3