diff options
author | Alexander Schmitz <arschmitz@gmail.com> | 2015-01-30 09:58:21 -0500 |
---|---|---|
committer | Alexander Schmitz <arschmitz@gmail.com> | 2015-03-11 16:05:40 -0400 |
commit | 144826d17548eb989f05330cc45d23cc9dbd5cc2 (patch) | |
tree | 14b3de5e3a63ef40130a0434fbf96da5003661f4 /tests/unit | |
parent | 53d1bc2ce1d2213a40d6edbddf9ed3336ca7d10e (diff) | |
download | jquery-ui-144826d17548eb989f05330cc45d23cc9dbd5cc2.tar.gz jquery-ui-144826d17548eb989f05330cc45d23cc9dbd5cc2.zip |
Menu: Use new has/lacksClasses assertions for all class checks
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/menu/menu_core.js | 4 | ||||
-rw-r--r-- | tests/unit/menu/menu_events.js | 4 | ||||
-rw-r--r-- | tests/unit/menu/menu_methods.js | 14 | ||||
-rw-r--r-- | tests/unit/menu/menu_options.js | 40 |
4 files changed, 34 insertions, 28 deletions
diff --git a/tests/unit/menu/menu_core.js b/tests/unit/menu/menu_core.js index 955424477..9c3ba873a 100644 --- a/tests/unit/menu/menu_core.js +++ b/tests/unit/menu/menu_core.js @@ -55,7 +55,7 @@ asyncTest( "#9044: Autofocus issue with dialog opened from menu widget", functio }); }); -asyncTest( "#9532: Need a way in Menu to keep ui-state-active class on selected item for Selectmenu", function() { +asyncTest( "#9532: Need a way in Menu to keep ui-state-active class on selected item for Selectmenu", function( assert ) { expect( 1 ); var element = $( "#menu1" ).menu(), firstChild = element.children().eq( 0 ), @@ -64,7 +64,7 @@ asyncTest( "#9532: Need a way in Menu to keep ui-state-active class on selected element.menu( "focus", null, firstChild ); wrapper.addClass( "ui-state-active" ); setTimeout( function() { - ok( wrapper.is( ".ui-state-active" ) ); + assert.hasClasses( wrapper, "ui-state-active" ); start(); }); }); diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js index ad13de3b8..4985e0677 100644 --- a/tests/unit/menu/menu_events.js +++ b/tests/unit/menu/menu_events.js @@ -671,13 +671,13 @@ test( "#9469: Stopping propagation in a select event should not suppress subsequ equal( logOutput(), "1,2", "Both select events were not triggered." ); }); -asyncTest( "#10571: When typing in a menu, only menu-items should be focused", function() { +asyncTest( "#10571: When typing in a menu, only menu-items should be focused", function( assert ) { expect( 3 ); var element = $( "#menu8" ).menu({ focus: function( event, ui ) { equal( ui.item.length, 1, "There should only be one match when filtering" ); - ok( ui.item.hasClass( "ui-menu-item" ), "element is .ui-menu-item" ); + assert.hasClasses( ui.item, "ui-menu-item" ); equal( ui.item.text(), "-Saarland", "element has correct text" ); } }); diff --git a/tests/unit/menu/menu_methods.js b/tests/unit/menu/menu_methods.js index 1cc3ec179..840ccbd17 100644 --- a/tests/unit/menu/menu_methods.js +++ b/tests/unit/menu/menu_methods.js @@ -20,7 +20,7 @@ test( "destroy", function() { }); }); -test( "enable/disable", function() { +test( "enable/disable", function( assert ) { expect( 3 ); var element = $( "#menu1" ).menu({ select: function() { @@ -28,12 +28,12 @@ test( "enable/disable", function() { } }); element.menu( "disable" ); - ok( element.is( ".ui-state-disabled" ), "Missing ui-state-disabled class" ); + assert.hasClasses( element, "ui-state-disabled" ); log( "click", true ); click( element, "1" ); log( "afterclick" ); element.menu( "enable" ); - ok( element.not( ".ui-state-disabled" ), "Has ui-state-disabled class" ); + assert.lacksClasses( element, "ui-state-disabled" ); log( "click" ); click( element, "1" ); log( "afterclick" ); @@ -63,18 +63,18 @@ test( "refresh submenu", function() { equal( element.find( "ul:first .ui-menu-item" ).length, 4 ); }); -test( "refresh icons (see #9377)", function() { +test( "refresh icons (see #9377)", function( assert ) { expect( 3 ); var element = $( "#menu1" ).menu(); - ok( !element.hasClass( "ui-menu-icons") ); + assert.lacksClasses( element, "ui-menu-icons" ); element.find( "li:first .ui-menu-item-wrapper" ) .html( "<span class='ui-icon ui-icon-disk'></span>Save</a>" ); element.menu( "refresh" ); - ok( element.hasClass( "ui-menu-icons" ) ); + assert.hasClasses( element, "ui-menu-icons" ); element.find( "li:first .ui-menu-item-wrapper" ).html( "Save" ); element.menu( "refresh" ); - ok( !element.hasClass( "ui-menu-icons" ) ); + assert.lacksClasses( element, "ui-menu-icons" ); }); test( "widget", function() { diff --git a/tests/unit/menu/menu_options.js b/tests/unit/menu/menu_options.js index 3b71037e8..39ba62e3c 100644 --- a/tests/unit/menu/menu_options.js +++ b/tests/unit/menu/menu_options.js @@ -10,7 +10,7 @@ module( "menu: options", { } }); -test( "{ disabled: true }", function() { +test( "{ disabled: true }", function( assert ) { expect( 2 ); var element = $( "#menu1" ).menu({ disabled: true, @@ -18,14 +18,14 @@ test( "{ disabled: true }", function() { log(); } }); - ok( element.hasClass( "ui-state-disabled" ), "Missing ui-state-disabled class" ); + assert.hasClasses( element, "ui-state-disabled" ); log( "click", true ); click( element, "1" ); log( "afterclick" ); equal( logOutput(), "click,afterclick", "Click order not valid." ); }); -test( "{ disabled: false }", function() { +test( "{ disabled: false }", function( assert ) { expect( 2 ); var element = $( "#menu1" ).menu({ disabled: false, @@ -33,44 +33,50 @@ test( "{ disabled: false }", function() { log(); } }); - ok( !element.hasClass( "ui-state-disabled" ), "Has ui-state-disabled class" ); + assert.lacksClasses( element, "ui-state-disabled" ); log( "click", true ); click( element, "1" ); log( "afterclick" ); equal( logOutput(), "click,1,afterclick", "Click order not valid." ); }); -test( "{ icons: default }", function() { - expect( 2 ); +test( "{ icons: default }", function( assert ) { + expect( 8 ); var element = $( "#menu2" ).menu(); - equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon ui-icon-caret-1-e" ); + element.find( ".ui-menu-icon" ).each( function() { + assert.hasClasses( this, "ui-menu-icon ui-icon ui-icon-caret-1-e" ); + }); element.menu( "option", "icons.submenu", "ui-icon-triangle-1-e" ); - equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon ui-icon-triangle-1-e" ); + element.find( ".ui-menu-icon" ).each( function() { + assert.hasClasses( this, "ui-menu-icon ui-icon ui-icon-triangle-1-e" ); + }); }); -test( "{ icons: { submenu: 'custom' } }", function() { - expect( 1 ); +test( "{ icons: { submenu: 'custom' } }", function( assert ) { + expect( 4 ); var element = $( "#menu2" ).menu({ icons: { submenu: "custom-class" } }); - equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon custom-class" ); + element.find( ".ui-menu-icon" ).each( function() { + assert.hasClasses( this, "ui-menu-icon ui-icon custom-class" ); + }); }); // TODO: test menus option // TODO: test position option -test( "{ role: 'menu' } ", function() { +test( "{ role: 'menu' } ", function( assert ) { var element = $( "#menu1" ).menu(), items = element.find( "li" ); expect( 2 + 3 * items.length ); equal( element.attr( "role" ), "menu" ); ok( items.length > 0, "number of menu items" ); items.each(function( item ) { - ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" ); + assert.hasClasses( $( this ), "ui-menu-item" ); equal( $( this ).find( ".ui-menu-item-wrapper" ).attr( "role" ), "menuitem", "menu item ("+ item + ") role" ); equal( $( this ).find( ".ui-menu-item-wrapper" ).attr( "tabindex" ), "-1", @@ -78,7 +84,7 @@ test( "{ role: 'menu' } ", function() { }); }); -test( "{ role: 'listbox' } ", function() { +test( "{ role: 'listbox' } ", function( assert ) { var element = $( "#menu1" ).menu({ role: "listbox" }), @@ -87,7 +93,7 @@ test( "{ role: 'listbox' } ", function() { equal( element.attr( "role" ), "listbox" ); ok( items.length > 0, "number of menu items" ); items.each(function( item ) { - ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" ); + assert.hasClasses( $( this ), "ui-menu-item" ); equal( $( this ).find( ".ui-menu-item-wrapper" ).attr( "role" ), "option", "menu item ("+ item + ") role" ); equal( $( this ).find( ".ui-menu-item-wrapper" ).attr( "tabindex" ), "-1", @@ -95,7 +101,7 @@ test( "{ role: 'listbox' } ", function() { }); }); -test( "{ role: null }", function() { +test( "{ role: null }", function( assert ) { var element = $( "#menu1" ).menu({ role: null }), @@ -104,7 +110,7 @@ test( "{ role: null }", function() { strictEqual( element.attr( "role" ), undefined ); ok( items.length > 0, "number of menu items" ); items.each(function( item ) { - ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" ); + assert.hasClasses( $( this ), "ui-menu-item" ); equal( $( this ).find( ".ui-menu-item-wrapper" ).attr( "role" ), undefined, "menu item ("+ item + ") role" ); equal( $( this ).find( ".ui-menu-item-wrapper" ).attr( "tabindex" ), "-1", |