diff options
author | Alexander Schmitz <arschmitz@gmail.com> | 2015-02-02 19:37:32 -0500 |
---|---|---|
committer | Alexander Schmitz <arschmitz@gmail.com> | 2015-03-11 16:05:40 -0400 |
commit | 8f26f0ad1ab384ca7a2308ce5128c2bb28fea2ce (patch) | |
tree | 9626086cdb83350a881ed8e369994c31e49855bf /tests/unit | |
parent | cba7fd546689835297aae40e69636f653a9e2dba (diff) | |
download | jquery-ui-8f26f0ad1ab384ca7a2308ce5128c2bb28fea2ce.tar.gz jquery-ui-8f26f0ad1ab384ca7a2308ce5128c2bb28fea2ce.zip |
Sortable: Use new has/lacksClasses assertions for all class checks
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/sortable/sortable.html | 1 | ||||
-rw-r--r-- | tests/unit/sortable/sortable_core.js | 16 | ||||
-rw-r--r-- | tests/unit/sortable/sortable_methods.js | 6 | ||||
-rw-r--r-- | tests/unit/sortable/sortable_options.js | 8 |
4 files changed, 17 insertions, 14 deletions
diff --git a/tests/unit/sortable/sortable.html b/tests/unit/sortable/sortable.html index f13b895b8..49b347582 100644 --- a/tests/unit/sortable/sortable.html +++ b/tests/unit/sortable/sortable.html @@ -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" ], diff --git a/tests/unit/sortable/sortable_core.js b/tests/unit/sortable/sortable_core.js index 54069a9bf..ac027486b 100644 --- a/tests/unit/sortable/sortable_core.js +++ b/tests/unit/sortable/sortable_core.js @@ -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" ); diff --git a/tests/unit/sortable/sortable_methods.js b/tests/unit/sortable/sortable_methods.js index 9c0a86a35..822bc082e 100644 --- a/tests/unit/sortable/sortable_methods.js +++ b/tests/unit/sortable/sortable_methods.js @@ -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" ); diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js index 90cf765a2..03308cb18 100644 --- a/tests/unit/sortable/sortable_options.js +++ b/tests/unit/sortable/sortable_options.js @@ -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" ); |