Skip to content
Permalink
Browse files

Sortable: Convert tests to new infrastructure

Ref #10119
Ref gh-1528
  • Loading branch information...
scottgonzalez committed Apr 6, 2015
1 parent a856dd9 commit 31e36e6ae4e1552b9a79595695c13dce4f416d0b
@@ -4,33 +4,8 @@
<meta charset="utf-8">
<title>jQuery UI Sortable Test Suite</title>

<script src="../../jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<script src="../../../external/qunit/qunit.js"></script>
<script src="../../../external/jquery-simulate/jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="../../../external/qunit-assert-classes/qunit-assert-classes.js"></script>
<script>
TestHelpers.loadResources({
css: [ "core" ],
js: [
"ui/core.js",
"ui/widget.js",
"ui/mouse.js",
"ui/sortable.js",
"ui/draggable.js"
]
});
</script>

<script src="sortable_common.js"></script>
<script src="sortable_core.js"></script>
<script src="sortable_events.js"></script>
<script src="sortable_methods.js"></script>
<script src="sortable_options.js"></script>
<script src="sortable_test_helpers.js"></script>

<script src="../swarminject.js"></script>
<script src="../../lib/css.js" data-modules="core"></script>
<script src="../../lib/bootstrap.js" data-widget="sortable"></script>
<style>
#sortable, #sortable2 {
position:relative;
@@ -1,4 +1,9 @@
TestHelpers.commonWidgetTests( "sortable", {
define( [
"lib/common",
"ui/sortable"
], function( common ) {

common.testWidget( "sortable", {
defaults: {
appendTo: "parent",
axis: false,
@@ -44,3 +49,5 @@ TestHelpers.commonWidgetTests( "sortable", {
update: null
}
});

} );
@@ -1,8 +1,8 @@
/*
* sortable_core.js
*/

(function( $ ) {
define( [
"jquery",
"./sortable_test_helpers",
"ui/sortable"
], function( $, sortableTestHelpers ) {

module( "sortable: core" );

@@ -13,7 +13,7 @@ test( "#9314: Sortable: Items cannot be dragged directly into bottom position",
connectWith: ".connectWith"
});

TestHelpers.sortable.sort( $( "li", el[ 1 ] )[ 0 ], 0, -12, 5, "Dragging the sortable into connected sortable" );
sortableTestHelpers.sort( $( "li", el[ 1 ] )[ 0 ], 0, -12, 5, "Dragging the sortable into connected sortable" );
});

test( "ui-sortable-handle applied to appropriate element", function( assert ) {
@@ -39,4 +39,4 @@ test( "ui-sortable-handle applied to appropriate element", function( assert ) {
equal( el.find( ".ui-sortable-handle" ).length, 0, "class name removed on destroy" );
});

})( jQuery );
} );
@@ -1,7 +1,9 @@
/*
* sortable_events.js
*/
(function($) {
define( [
"jquery",
"./sortable_test_helpers",
"ui/sortable",
"ui/draggable"
], function( $, sortableTestHelpers ) {

module("sortable: events");

@@ -170,7 +172,7 @@ test("#3019: Stop fires too early", function() {
}
});

TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, "Dragging the sortable");
sortableTestHelpers.sort($("li", el)[0], 0, 44, 2, "Dragging the sortable");
equal(helper, null, "helper should be false");

});
@@ -373,4 +375,4 @@ test("deactivate", function() {
});
*/

})(jQuery);
} );
@@ -1,7 +1,8 @@
/*
* sortable_methods.js
*/
(function($) {
define( [
"jquery",
"./sortable_test_helpers",
"ui/sortable"
], function( $, sortableTestHelpers ) {

module("sortable: methods");

@@ -47,7 +48,7 @@ test("enable", function() {

el = $("#sortable").sortable({ disabled: true });

TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, ".sortable({ disabled: true })");
sortableTestHelpers.sort($("li", el)[0], 0, 44, 0, ".sortable({ disabled: true })");

el.sortable("enable");
equal(el.sortable("option", "disabled"), false, "disabled option getter");
@@ -57,7 +58,7 @@ test("enable", function() {
el.sortable("option", "disabled", false);
equal(el.sortable("option", "disabled"), false, "disabled option setter");

TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable('option', 'disabled', false)");
sortableTestHelpers.sort($("li", el)[0], 0, 44, 2, ".sortable('option', 'disabled', false)");

expected = $("<div></div>").sortable(),
actual = expected.sortable("enable");
@@ -70,23 +71,23 @@ test( "disable", function( assert ) {
var chainable,
element = $( "#sortable" ).sortable({ disabled: false });

TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" );
sortableTestHelpers.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" );

chainable = element.sortable( "disable" );
TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 0, "disabled.sortable getter" );
sortableTestHelpers.sort( $( "li", element )[ 0 ], 0, 44, 0, "disabled.sortable getter" );

element.sortable( "destroy" );

element.sortable({ disabled: false });
TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" );
sortableTestHelpers.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" );

TestHelpers.sortable.sort($( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" );
sortableTestHelpers.sort($( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" );
equal( chainable, element, "disable is chainable" );
});

@@ -125,4 +126,4 @@ test( "refresh() should update the positions of initially empty lists (see #7498
equal( changeCount, 1 );
});

})(jQuery);
} );
@@ -1,7 +1,7 @@
/*
* sortable_options.js
*/
(function($) {
define( [
"jquery",
"ui/sortable"
], function( $ ) {

module("sortable: options");

@@ -493,4 +493,4 @@ test("{ zIndex: false }", function() {
ok(false, "missing test - untested code is broken code.");
});
*/
})(jQuery);
} );
@@ -1,4 +1,6 @@
TestHelpers.sortable = {
define( function() {

return {
sort: function( handle, dx, dy, index, msg ) {
$( handle ).simulate( "drag", {
dx: dx,
@@ -7,3 +9,5 @@ TestHelpers.sortable = {
equal( $( handle ).parent().children().index( handle ), index, msg );
}
};

} );

0 comments on commit 31e36e6

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.