]> source.dussan.org Git - jquery-ui.git/commitdiff
Draggable: Use new has/lacksClasses assertions for all class checks
authorAlexander Schmitz <arschmitz@gmail.com>
Fri, 30 Jan 2015 14:57:30 +0000 (09:57 -0500)
committerAlexander Schmitz <arschmitz@gmail.com>
Wed, 11 Mar 2015 20:05:39 +0000 (16:05 -0400)
tests/unit/dialog/dialog_methods.js
tests/unit/draggable/draggable.html
tests/unit/draggable/draggable_core.js
tests/unit/draggable/draggable_methods.js

index c012f80a5409fbae7cee620e74a67b294a2a4e58..c92f1f1b4a7a1d85753c707419b03b2012d05fe3 100644 (file)
@@ -105,7 +105,7 @@ test( "enable/disable disabled", function( assert ) {
        var element = $( "<div></div>" ).dialog();
        element.dialog( "disable" );
        equal(element.dialog( "option", "disabled" ), false, "disable method doesn't do anything" );
-       assert.lacksClasses( element, "ui-dialog-disabled ui-state-disabled" );
+       assert.lacksClasses( element, "ui-dialog-disabled ui-state-disabled", "disable method doesn't add classes" );
        ok( !element.dialog( "widget" ).attr( "aria-disabled" ), "disable method doesn't add aria-disabled" );
 });
 
index eb4985adc370fad2bc9ba23722941b67f2badbba..a8fdf91ca5bcf0945382526b42a0975f3aeb51da 100644 (file)
@@ -68,6 +68,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" ],
index 81c31e22f1de76c1c852f19ebb0f858255fbe25e..8b389516360e2a042f219dc09ce9006420d1a63f 100644 (file)
@@ -318,35 +318,34 @@ asyncTest( "blur behavior", function() {
        });
 });
 
-test( "ui-draggable-handle assigned to appropriate element", function() {
+test( "ui-draggable-handle assigned to appropriate element", function( assert ) {
        expect( 5 );
 
        var p = $( "<p>" ).appendTo( "#qunit-fixture" ),
                element = $( "<div><p></p></div>" ).appendTo( "#qunit-fixture" ).draggable();
-       ok( element.hasClass( "ui-draggable-handle" ), "handle is element by default" );
+       assert.hasClasses( element, "ui-draggable-handle" );
 
        element.draggable( "option", "handle", "p" );
-       ok( !element.hasClass( "ui-draggable-handle" ), "removed from element" );
-       ok( element.find( "p" ).hasClass( "ui-draggable-handle" ), "added to handle" );
-
-       ok( !p.hasClass( "ui-draggable-handle" ),
+       assert.lacksClasses( element, "ui-draggable-handle" );
+       assert.hasClasses( element.find( "p" ), "ui-draggable-handle",
                "ensure handle class name is constrained within the draggble (#10212)" );
+       assert.lacksClasses( p, "ui-draggable-handle" );
 
        element.draggable( "destroy" );
-       ok( !element.find( "p" ).hasClass( "ui-draggable-handle" ), "removed in destroy()" );
+       assert.lacksClasses( element.find( "p" ), "ui-draggable-handle" );
 });
 
-test( "ui-draggable-handle managed correctly in nested draggables", function() {
+test( "ui-draggable-handle managed correctly in nested draggables", function( assert ) {
        expect( 4 );
        var parent = $( "<div><div></div></div>" ).draggable().appendTo( "#qunit-fixture" ),
                child = parent.find( "div" ).draggable();
 
-       ok( parent.hasClass( "ui-draggable-handle" ), "parent has class name on init" );
-       ok( child.hasClass( "ui-draggable-handle" ), "child has class name on init" );
+       assert.hasClasses( parent, "ui-draggable-handle", "parent has class name on init" );
+       assert.hasClasses( child, "ui-draggable-handle", "child has class name on init" );
 
        parent.draggable( "destroy" );
-       ok( !parent.hasClass( "ui-draggable-handle" ), "parent loses class name on destroy" );
-       ok( child.hasClass( "ui-draggable-handle" ), "child retains class name on destroy" );
+       assert.lacksClasses( parent, "ui-draggable-handle", "parent loses class name on destroy" );
+       assert.hasClasses( child, "ui-draggable-handle", "child retains class name on destroy" );
 });
 
 // http://bugs.jqueryui.com/ticket/7772
index 351d57764f04a7cb21dea21422999f9a5c59f78b..210f48964ed24168fbe31e9b56e57a91f5521456 100644 (file)
@@ -73,7 +73,7 @@ test( "enable", function() {
        equal( actual, expected, "enable is chainable" );
 });
 
-test( "disable", function() {
+test( "disable", function( assert ) {
        expect( 14 );
 
        element = $( "#draggable2" ).draggable({ disabled: false });
@@ -91,9 +91,9 @@ test( "disable", function() {
        equal( element.draggable( "option", "disabled" ), true, "disabled option setter" );
        TestHelpers.draggable.shouldNotDrag( element, ".draggable('option', 'disabled', true)" );
 
-       ok( !element.draggable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" );
+       assert.lacksClasses( element.draggable( "widget" ), "ui-state-disabled" );
        ok( !element.draggable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
-       ok( element.draggable( "widget" ).hasClass( "ui-draggable-disabled" ), "element gets ui-draggable-disabled" );
+       assert.hasClasses( element.draggable( "widget" ), "ui-draggable-disabled" );
 
        var expected = element.draggable(),
                actual = expected.draggable( "disable" );