mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Sortable: Use new has/lacksClasses assertions for all class checks
This commit is contained in:
parent
cba7fd5466
commit
8f26f0ad1a
@ -9,6 +9,7 @@
|
||||
<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" ],
|
||||
|
@ -16,22 +16,24 @@ test( "#9314: Sortable: Items cannot be dragged directly into bottom position",
|
||||
TestHelpers.sortable.sort( $( "li", el[ 1 ] )[ 0 ], 0, -12, 5, "Dragging the sortable into connected sortable" );
|
||||
});
|
||||
|
||||
test( "ui-sortable-handle applied to appropriate element", function() {
|
||||
expect( 6 );
|
||||
test( "ui-sortable-handle applied to appropriate element", function( assert ) {
|
||||
expect( 8 );
|
||||
var item = "<li><p></p></li>",
|
||||
el = $( "<ul>" + item + item + "</ul>" )
|
||||
.sortable()
|
||||
.appendTo( "#qunit-fixture" );
|
||||
|
||||
ok( el.find( "li:first" ).hasClass( "ui-sortable-handle" ), "defaults to item" );
|
||||
ok( el.find( "li:last" ).hasClass( "ui-sortable-handle" ), "both items received class name" );
|
||||
assert.hasClasses( el.find( "li:first" ), "ui-sortable-handle" );
|
||||
assert.hasClasses( el.find( "li:last" ), "ui-sortable-handle" );
|
||||
|
||||
el.sortable( "option", "handle", "p" );
|
||||
ok( !el.find( "li" ).hasClass( "ui-sortable-handle" ), "removed on change" );
|
||||
ok( el.find( "p" ).hasClass( "ui-sortable-handle" ), "applied to handle" );
|
||||
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" );
|
||||
ok( el.find( "p:last" ).hasClass( "ui-sortable-handle" ), "class name applied on 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" );
|
||||
|
@ -64,7 +64,7 @@ test("enable", function() {
|
||||
equal(actual, expected, "enable is chainable");
|
||||
});
|
||||
|
||||
test( "disable", function() {
|
||||
test( "disable", function( assert ) {
|
||||
expect( 9 );
|
||||
|
||||
var chainable,
|
||||
@ -82,9 +82,9 @@ test( "disable", function() {
|
||||
element.sortable( "option", "disabled", true);
|
||||
equal( element.sortable( "option", "disabled" ), true, "disabled option setter" );
|
||||
|
||||
ok( !element.sortable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" );
|
||||
assert.lacksClasses( element.sortable( "widget" ), "ui-state-disabled" );
|
||||
ok( !element.sortable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
|
||||
ok( element.sortable( "widget" ).hasClass( "ui-sortable-disabled" ), "element gets ui-sortable-disabled" );
|
||||
assert.hasClasses( element.sortable( "widget" ), "ui-sortable-disabled" );
|
||||
|
||||
TestHelpers.sortable.sort($( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" );
|
||||
equal( chainable, element, "disable is chainable" );
|
||||
|
@ -343,13 +343,13 @@ test( "{ placeholder: false } img", function() {
|
||||
});
|
||||
});
|
||||
|
||||
test( "{ placeholder: String }", function() {
|
||||
test( "{ placeholder: String }", function( assert ) {
|
||||
expect( 1 );
|
||||
|
||||
var element = $( "#sortable" ).sortable({
|
||||
placeholder: "test",
|
||||
start: function( event, ui ) {
|
||||
ok( ui.placeholder.hasClass( "test" ), "placeholder has class" );
|
||||
assert.hasClasses( ui.placeholder, "test" );
|
||||
}
|
||||
});
|
||||
|
||||
@ -358,7 +358,7 @@ test( "{ placeholder: String }", function() {
|
||||
});
|
||||
});
|
||||
|
||||
test( "{ placholder: String } tr", function() {
|
||||
test( "{ placholder: String } tr", function( assert ) {
|
||||
expect( 4 );
|
||||
|
||||
var originalWidths,
|
||||
@ -368,7 +368,7 @@ test( "{ placholder: String } tr", function() {
|
||||
var currentWidths = otherRow.children().map(function() {
|
||||
return $( this ).width();
|
||||
}).get();
|
||||
ok( ui.placeholder.hasClass( "test" ), "placeholder has class" );
|
||||
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" );
|
||||
|
Loading…
Reference in New Issue
Block a user