]> source.dussan.org Git - jquery-ui.git/commitdiff
Widget: Use new has/lacksClasses assertions for all class checks
authorAlexander Schmitz <arschmitz@gmail.com>
Tue, 3 Feb 2015 00:38:53 +0000 (19:38 -0500)
committerAlexander Schmitz <arschmitz@gmail.com>
Wed, 11 Mar 2015 20:05:41 +0000 (16:05 -0400)
tests/unit/widget/widget_core.js

index 4e5b023490a65d3c9ec06de3aac7bcb9eeba3e50..74d6af9da0a2125bedfeef9d7cd5cdf8cfbfd5e5 100644 (file)
@@ -983,7 +983,7 @@ test( "_off() - all events", function() {
        element.trigger( "bar" );
 });
 
-test( "._hoverable()", function() {
+test( "._hoverable()", function( assert ) {
        expect( 10 );
        $.widget( "ui.testWidget", {
                _create: function() {
@@ -992,30 +992,30 @@ test( "._hoverable()", function() {
        });
 
        var div = $( "#widget" ).testWidget().children();
-       ok( !div.hasClass( "ui-state-hover" ), "not hovered on init" );
+       assert.lacksClasses( div, "ui-state-hover", "not hovered on init" );
        div.trigger( "mouseenter" );
-       ok( div.hasClass( "ui-state-hover" ), "hovered after mouseenter" );
+       assert.hasClasses( div, "ui-state-hover", "hovered after mouseenter" );
        div.trigger( "mouseleave" );
-       ok( !div.hasClass( "ui-state-hover" ), "not hovered after mouseleave" );
+       assert.lacksClasses( div, "ui-state-hover", "not hovered after mouseleave" );
 
        div.trigger( "mouseenter" );
-       ok( div.hasClass( "ui-state-hover" ), "hovered after mouseenter" );
+       assert.hasClasses( div, "ui-state-hover", "hovered after mouseenter" );
        $( "#widget" ).testWidget( "disable" );
-       ok( !div.hasClass( "ui-state-hover" ), "not hovered while disabled" );
+       assert.lacksClasses( div, "ui-state-hover", "not hovered while disabled" );
        div.trigger( "mouseenter" );
-       ok( !div.hasClass( "ui-state-hover" ), "can't hover while disabled" );
+       assert.lacksClasses( div, "ui-state-hover", "can't hover while disabled" );
        $( "#widget" ).testWidget( "enable" );
-       ok( !div.hasClass( "ui-state-hover" ), "enabling doesn't reset hover" );
+       assert.lacksClasses( div, "ui-state-hover", "enabling doesn't reset hover" );
 
        div.trigger( "mouseenter" );
-       ok( div.hasClass( "ui-state-hover" ), "hovered after mouseenter" );
+       assert.hasClasses( div, "ui-state-hover", "hovered after mouseenter" );
        $( "#widget" ).testWidget( "destroy" );
-       ok( !div.hasClass( "ui-state-hover" ), "not hovered after destroy" );
+       assert.lacksClasses( div, "ui-state-hover", "not hovered after destroy" );
        div.trigger( "mouseenter" );
-       ok( !div.hasClass( "ui-state-hover" ), "event handler removed on destroy" );
+       assert.lacksClasses( div, "ui-state-hover", "event handler removed on destroy" );
 });
 
-test( "._focusable()", function() {
+test( "._focusable()", function( assert ) {
        expect( 10 );
        $.widget( "ui.testWidget", {
                _create: function() {
@@ -1024,27 +1024,27 @@ test( "._focusable()", function() {
        });
 
        var div = $( "#widget" ).testWidget().children();
-       ok( !div.hasClass( "ui-state-focus" ), "not focused on init" );
+       assert.lacksClasses( div, "ui-state-focus", "not focused on init" );
        div.trigger( "focusin" );
-       ok( div.hasClass( "ui-state-focus" ), "focused after explicit focus" );
+       assert.hasClasses( div, "ui-state-focus", "focused after explicit focus" );
        div.trigger( "focusout" );
-       ok( !div.hasClass( "ui-state-focus" ), "not focused after blur" );
+       assert.lacksClasses( div, "ui-state-focus", "not focused after blur" );
 
        div.trigger( "focusin" );
-       ok( div.hasClass( "ui-state-focus" ), "focused after explicit focus" );
+       assert.hasClasses( div, "ui-state-focus", "focused after explicit focus" );
        $( "#widget" ).testWidget( "disable" );
-       ok( !div.hasClass( "ui-state-focus" ), "not focused while disabled" );
+       assert.lacksClasses( div, "ui-state-focus", "not focused while disabled" );
        div.trigger( "focusin" );
-       ok( !div.hasClass( "ui-state-focus" ), "can't focus while disabled" );
+       assert.lacksClasses( div, "ui-state-focus", "can't focus while disabled" );
        $( "#widget" ).testWidget( "enable" );
-       ok( !div.hasClass( "ui-state-focus" ), "enabling doesn't reset focus" );
+       assert.lacksClasses( div, "ui-state-focus", "enabling doesn't reset focus" );
 
        div.trigger( "focusin" );
-       ok( div.hasClass( "ui-state-focus" ), "focused after explicit focus" );
+       assert.hasClasses( div, "ui-state-focus", "focused after explicit focus" );
        $( "#widget" ).testWidget( "destroy" );
-       ok( !div.hasClass( "ui-state-focus" ), "not focused after destroy" );
+       assert.lacksClasses( div, "ui-state-focus", "not focused after destroy" );
        div.trigger( "focusin" );
-       ok( !div.hasClass( "ui-state-focus" ), "event handler removed on destroy" );
+       assert.lacksClasses( div, "ui-state-focus", "event handler removed on destroy" );
 });
 
 test( "._trigger() - no event, no ui", function() {