diff options
author | TJ VanToll <tj.vantoll@gmail.com> | 2014-09-26 17:34:22 -0400 |
---|---|---|
committer | TJ VanToll <tj.vantoll@gmail.com> | 2014-10-25 10:10:38 -0700 |
commit | e9643f6bfc922773e29e3084e64de0240b547f32 (patch) | |
tree | adb642df12433f050860e50f43c642802b278106 /tests/unit/selectmenu | |
parent | 4ac7b1f679de3df93f6a3681334ef0ecaf12bcb2 (diff) | |
download | jquery-ui-e9643f6bfc922773e29e3084e64de0240b547f32.tar.gz jquery-ui-e9643f6bfc922773e29e3084e64de0240b547f32.zip |
Selectmenu: Re-add wrappers to menu items
Diffstat (limited to 'tests/unit/selectmenu')
-rw-r--r-- | tests/unit/selectmenu/selectmenu_core.js | 87 |
1 files changed, 44 insertions, 43 deletions
diff --git a/tests/unit/selectmenu/selectmenu_core.js b/tests/unit/selectmenu/selectmenu_core.js index e9312d12f..0074c6f90 100644 --- a/tests/unit/selectmenu/selectmenu_core.js +++ b/tests/unit/selectmenu/selectmenu_core.js @@ -3,15 +3,15 @@ module( "selectmenu: core" ); asyncTest( "accessibility", function() { - var links, + var wrappers, element = $( "#speed" ).selectmenu(), button = element.selectmenu( "widget" ), menu = element.selectmenu( "menuWidget" ); button.simulate( "focus" ); - links = menu.find( "li.ui-menu-item" ); + wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" ); - expect( 12 + links.length * 2 ); + expect( 12 + wrappers.length * 2 ); setTimeout(function() { equal( button.attr( "role" ), "combobox", "button role" ); @@ -21,7 +21,7 @@ asyncTest( "accessibility", function() { equal( button.attr( "aria-owns" ), menu.attr( "id" ), "button aria-owns" ); equal( button.attr( "aria-labelledby" ), - links.eq( element[ 0 ].selectedIndex ).attr( "id" ), + wrappers.eq( element[ 0 ].selectedIndex ).attr( "id" ), "button link aria-labelledby" ); equal( button.attr( "tabindex" ), 0, "button link tabindex" ); @@ -32,10 +32,10 @@ asyncTest( "accessibility", function() { equal( menu.attr( "tabindex" ), 0, "menu tabindex" ); equal( menu.attr( "aria-activedescendant" ), - links.eq( element[ 0 ].selectedIndex ).attr( "id" ), + wrappers.eq( element[ 0 ].selectedIndex ).attr( "id" ), "menu aria-activedescendant" ); - $.each( links, function( index ) { + $.each( wrappers, function( index ) { var link = $( this ); equal( link.attr( "role" ), "option", "menu link #" + index +" role" ); equal( link.attr( "tabindex" ), -1, "menu link #" + index +" tabindex" ); @@ -58,7 +58,7 @@ $.each([ asyncTest( "state synchronization - after keydown on button - " + settings.type, function() { expect( 4 ); - var links, + var wrappers, element = $( settings.selector ).selectmenu(), button = element.selectmenu( "widget" ), menu = element.selectmenu( "menuWidget" ), @@ -69,17 +69,17 @@ $.each([ button.simulate( "focus" ); setTimeout(function() { - links = menu.find( "li.ui-menu-item" ); + wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" ); button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); equal( menu.attr( "aria-activedescendant" ), - links.eq( element[ 0 ].selectedIndex ).attr( "id" ), + wrappers.eq( element[ 0 ].selectedIndex ).attr( "id" ), "menu aria-activedescendant" ); equal( button.attr( "aria-activedescendant" ), - links.eq( element[ 0 ].selectedIndex ).attr( "id" ), + wrappers.eq( element[ 0 ].selectedIndex ).attr( "id" ), "button aria-activedescendant" ); equal( @@ -95,7 +95,7 @@ $.each([ asyncTest( "state synchronization - after click on item - " + settings.type, function() { expect( 4 ); - var links, + var wrappers, element = $( settings.selector ).selectmenu(), button = element.selectmenu( "widget" ), menu = element.selectmenu( "menuWidget" ), @@ -103,18 +103,18 @@ $.each([ button.simulate( "focus" ); setTimeout(function() { - links = menu.find( "li.ui-menu-item" ); + wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" ); button.trigger( "click" ); menu.find( "li" ).last().simulate( "mouseover" ).trigger( "click" ); equal( menu.attr( "aria-activedescendant" ), - links.eq( element[ 0 ].selectedIndex ).attr( "id" ), + wrappers.eq( element[ 0 ].selectedIndex ).attr( "id" ), "menu aria-activedescendant" ); equal( button.attr( "aria-activedescendant" ), - links.eq( element[ 0 ].selectedIndex ).attr( "id" ), + wrappers.eq( element[ 0 ].selectedIndex ).attr( "id" ), "button aria-activedescendant" ); equal( @@ -131,7 +131,7 @@ $.each([ "after focus item and keydown on button - " + settings.type, function() { expect( 4 ); - var links, + var wrappers, element = $( settings.selector ).selectmenu(), button = element.selectmenu( "widget" ), menu = element.selectmenu( "menuWidget" ), @@ -141,15 +141,15 @@ $.each([ button.simulate( "focus" ); setTimeout(function() { - links = menu.find( "li.ui-menu-item" ); + wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" ); // Open menu and click first item button.trigger( "click" ); - links.first().simulate( "mouseover" ).trigger( "click" ); + wrappers.first().simulate( "mouseover" ).trigger( "click" ); // Open menu again and hover item button.trigger( "click" ); - links.eq( 3 ).simulate( "mouseover" ); + wrappers.eq( 3 ).simulate( "mouseover" ); // Close and use keyboard control on button button.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); @@ -157,9 +157,9 @@ $.each([ setTimeout(function() { button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - equal( menu.attr( "aria-activedescendant" ), links.eq( 1 ).attr( "id" ), + equal( menu.attr( "aria-activedescendant" ), wrappers.eq( 1 ).attr( "id" ), "menu aria-activedescendant" ); - equal( button.attr( "aria-activedescendant" ), links.eq( 1 ).attr( "id" ), + equal( button.attr( "aria-activedescendant" ), wrappers.eq( 1 ).attr( "id" ), "button aria-activedescendant" ); equal( element.find( "option:selected" ).val(), options.eq( 1 ).val() , "original select state" ); @@ -172,26 +172,26 @@ $.each([ asyncTest( "item looping - " + settings.type, function() { expect( 4 ); - var links, + var wrappers, element = $( settings.selector ).selectmenu(), button = element.selectmenu( "widget" ), menu = element.selectmenu( "menuWidget" ); button.simulate( "focus" ); setTimeout(function() { - links = menu.find( "li.ui-menu-item" ); + wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" ); button.trigger( "click" ); - links.first().simulate( "mouseover" ).trigger( "click" ); + wrappers.first().simulate( "mouseover" ).trigger( "click" ); equal( element[ 0 ].selectedIndex, 0, "First item is selected" ); button.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); equal( element[ 0 ].selectedIndex, 0, "No looping beyond first item" ); button.trigger( "click" ); - links.last().simulate( "mouseover" ).trigger( "click" ); - equal( element[ 0 ].selectedIndex, links.length - 1, "Last item is selected" ); + wrappers.last().simulate( "mouseover" ).trigger( "click" ); + equal( element[ 0 ].selectedIndex, wrappers.length - 1, "Last item is selected" ); button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - equal( element[ 0 ].selectedIndex, links.length - 1, "No looping behind last item" ); + equal( element[ 0 ].selectedIndex, wrappers.length - 1, "No looping behind last item" ); start(); }); }); @@ -199,27 +199,27 @@ $.each([ asyncTest( "item focus and active state - " + settings.type, function() { expect( 4 ); - var items, focusedItem, + var wrappers, focusedItem, element = $( settings.selector ).selectmenu(), button = element.selectmenu( "widget" ), menu = element.selectmenu( "menuWidget" ); button.simulate( "focus" ); setTimeout(function() { - items = menu.find( "li.ui-menu-item" ); + wrappers = menu.find( "li.ui-menu-item .ui-menu-item-wrapper" ); button.trigger( "click" ); setTimeout(function() { checkItemClasses(); - items.eq( 3 ).simulate( "mouseover" ).trigger( "click" ); + wrappers.eq( 3 ).simulate( "mouseover" ).trigger( "click" ); button.trigger( "click" ); - items.eq( 2 ).simulate( "mouseover" ); + wrappers.eq( 2 ).simulate( "mouseover" ); $( document ).trigger( "click" ); button.trigger( "click" ); - items.eq( 1 ).simulate( "mouseover" ); + wrappers.eq( 1 ).simulate( "mouseover" ); $( document ).trigger( "click" ); button.trigger( "click" ); @@ -231,9 +231,9 @@ $.each([ }); function checkItemClasses() { - focusedItem = menu.find( "li.ui-state-focus" ); + focusedItem = menu.find( "li .ui-state-focus" ); equal( focusedItem.length, 1, "only one item has ui-state-focus class" ); - equal( focusedItem.attr( "id" ), items.eq( element[ 0 ].selectedIndex ).attr( "id" ), + equal( focusedItem.attr( "id" ), wrappers.eq( element[ 0 ].selectedIndex ).attr( "id" ), "selected item has ui-state-focus class" ); } }); @@ -241,7 +241,7 @@ $.each([ asyncTest( "empty option - " + settings.type, function() { expect( 7 ); - var button, menu, links, link, + var button, menu, wrappers, wrapper, element = $( settings.selector ); element.find( "option" ).first().text( "" ); @@ -251,20 +251,21 @@ $.each([ button.simulate( "focus" ); setTimeout(function() { - links = menu.find( "li:not(.ui-selectmenu-optgroup)" ); - link = links.first(); + wrappers = menu.find( "li:not(.ui-selectmenu-optgroup) .ui-menu-item-wrapper" ); + wrapper = wrappers.first(); button.trigger( "click" ); - equal( links.length, element.find( "option" ).length, + equal( wrappers.length, element.find( "option" ).length, "correct amount of list elements" ); - ok( link.outerHeight() > 10, "empty item seems to have reasonable height" ); - ok( link.attr( "id" ), "empty item has id attribute" ); - ok( link.hasClass( "ui-menu-item" ), "empty item has ui-menu-item class" ); - ok( !link.hasClass( "ui-menu-divider" ), + 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" ); - equal( link.attr( "tabindex" ), -1, "empty item has tabindex" ); - equal( link.attr( "role" ), "option", "empty item has role option" ); + equal( wrapper.attr( "tabindex" ), -1, "empty item has tabindex" ); + equal( wrapper.attr( "role" ), "option", "empty item has role option" ); start(); }); |