Skip to content
Permalink
Browse files

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

  • Loading branch information
arschmitz committed Jan 30, 2015
1 parent 9af91bc commit 8eb29fd90c6a05aaabe499097dd5d5a0073ddb13
@@ -294,7 +294,7 @@ $.each([
}
});

asyncTest( "empty option - " + settings.type, function() {
asyncTest( "empty option - " + settings.type, function( assert ) {
expect( 7 );

var button, menu, wrappers, wrapper,
@@ -316,10 +316,8 @@ $.each([
"correct amount of list elements" );
ok( wrapper.outerHeight() > 10, "empty item seems to have reasonable height" );
ok( wrapper.attr( "id" ), "empty item has id attribute" );
ok( wrapper.parent().hasClass( "ui-menu-item" ),
"empty item has ui-menu-item class" );
ok( !wrapper.hasClass( "ui-menu-divider" ),
"empty item does not have ui-menu-divider class" );
assert.hasClasses( wrapper.parent(), "ui-menu-item" );
assert.lacksClasses( wrapper, "ui-menu-divider" );
equal( wrapper.attr( "tabindex" ), -1, "empty item has tabindex" );
equal( wrapper.attr( "role" ), "option", "empty item has role option" );

@@ -114,7 +114,7 @@ test( "refresh - disabled select", function() {
equal( menu.attr( "aria-disabled" ), "true", "menu ARIA" );
});

test( "refresh - disabled option", function() {
test( "refresh - disabled option", function( assert ) {
expect( 1 );

var disabledItem,
@@ -125,10 +125,10 @@ test( "refresh - disabled option", function() {
element.selectmenu( "refresh" );

disabledItem = menu.find( "li" ).not( ".ui-selectmenu-optgroup" ).eq( 2 );
ok( disabledItem.hasClass( "ui-state-disabled" ), "class" );
assert.hasClasses( disabledItem, "ui-state-disabled" );
});

test( "refresh - disabled optgroup", function() {
test( "refresh - disabled optgroup", function( assert ) {
var i, item,
element = $( "#files" ).selectmenu(),
menu = element.selectmenu( "menuWidget" ).parent(),
@@ -141,7 +141,8 @@ test( "refresh - disabled optgroup", function() {
element.selectmenu( "refresh" );

item = menu.find( "li.ui-selectmenu-optgroup" ).first();
ok( item.hasClass( "ui-state-disabled" ), "class" );

assert.hasClasses( item, "ui-state-disabled" );

equal(
menu.find( "li" ).not( ".ui-selectmenu-optgroup" ).filter( ".ui-state-disabled" ).length,
@@ -150,7 +151,7 @@ test( "refresh - disabled optgroup", function() {
);
for ( i = 0; i < originalDisabledOptions.length; i++ ) {
item = item.next( "li" );
ok( item.hasClass( "ui-state-disabled" ), "item #" + i + ": class" );
assert.hasClasses( item, "ui-state-disabled" );
}
});

@@ -168,15 +169,15 @@ test( "refresh - remove all options", function() {
equal( menu.children().length, 0, "Empty menu" );
});

test( "widget and menuWidget", function() {
test( "widget and menuWidget", function( assert ) {
expect( 4 );

var element = $( "#speed" ).selectmenu(),
button = element.selectmenu( "widget" ),
menu = element.selectmenu( "menuWidget" );

equal( button.length, 1, "button: one element" );
ok( button.is( ".ui-selectmenu-button" ), "button: class" );
assert.hasClasses( button, "ui-selectmenu-button" );

equal( menu.length, 1, "Menu Widget: one element" );
ok( menu.is( "ul.ui-menu" ), "Menu Widget: element and class" );
@@ -67,21 +67,20 @@ test( "appendTo: ui-front", function() {
$( "#selectmenu-wrap2" )[ 0 ], "empty jQuery object, inside .ui-front" );
});

test( "CSS styles", function() {
expect( 2 );
test( "CSS styles", function( assert ) {
expect( 5 );

var element = $( "#speed" ).selectmenu(),
button = element.selectmenu( "widget" ),
menu = element.selectmenu( "menuWidget" );

element.selectmenu( "open" );
ok(
button.hasClass( "ui-corner-top" ) && !button.hasClass( "ui-corner-all" ) &&
button.find( "span.ui-icon" ).hasClass( "ui-icon-triangle-1-s" ),
"button styles dropdown"
);
ok( menu.hasClass( "ui-corner-bottom" ) && !menu.hasClass( "ui-corner-all" ),
"menu styles dropdown" );

assert.hasClasses( button, "ui-corner-top" );
assert.lacksClasses( button, "ui-corner-all" );
assert.hasClasses( button.find( "span.ui-icon" ), "ui-icon-triangle-1-s" );
assert.hasClasses( menu, "ui-corner-bottom" );
assert.lacksClasses( button, "ui-corner-all" );
});

test( "width", function() {

0 comments on commit 8eb29fd

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