Skip to content
Permalink
Browse files

Widget: Use new has/lacksClasses assertions for all class checks

  • Loading branch information
arschmitz committed Feb 3, 2015
1 parent 7b01dc3 commit 61232cb745535687a4c26dac149c9f9f083c518c
Showing with 22 additions and 22 deletions.
  1. +22 −22 tests/unit/widget/widget_core.js
@@ -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() {

0 comments on commit 61232cb

Please sign in to comment.
You can’t perform that action at this time.