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

This commit is contained in:
Alexander Schmitz 2015-02-02 19:38:53 -05:00
parent 7b01dc3d2c
commit 61232cb745

View 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() {