Skip to content
Permalink
Browse files

Selectmenu: cleanup unit tests, removing mass test

  • Loading branch information...
fnagel committed Feb 21, 2012
1 parent 4526357 commit afcdd6a75cb4c8e1e74b84ccfbdb543b35342337
Showing with 26 additions and 42 deletions.
  1. +25 −40 tests/unit/selectmenu/selectmenu_core.js
  2. +1 −2 tests/unit/selectmenu/selectmenu_methods.js
@@ -4,29 +4,27 @@ module( "selectmenu: core" );

test("accessibility", function () {
var element = $('#speed').selectmenu(),
button = element.selectmenu("widget").parent(),
menu = element.selectmenu("menuWidget").parent(),
link = button.find("a"),
selected = element.find("option:selected"),
ul = menu.children("ul");
button = element.selectmenu("widget"),
menu = element.selectmenu("menuWidget"),
selected = element.find("option:selected");

link.simulate( "focus" );
var links = ul.find("li.ui-menu-item a");
button.simulate( "focus" );
var links = menu.find("li.ui-menu-item a");

expect(12 + links.length * 2);

equals( link.attr("role"), "combobox", "button link role" );
equals( link.attr("aria-haspopup"), "true", "button link aria-haspopup" );
equals( link.attr("aria-expanded"), "false", "button link aria-expanded" );
equals( link.attr("aria-autocomplete"), "list", "button link aria-autocomplete" );
equals( link.attr("aria-owns"), ul.attr("id"), "button link aria-owns" );
equals( link.attr("tabindex"), 0, "button link tabindex" );

equals( ul.attr("role"), "listbox", "menu role" );
equals( ul.attr("aria-labelledby"), link.attr("id"), "menu aria-labelledby" );
equals( ul.attr("aria-hidden"), "true", "menu aria-hidden" );
equals( ul.attr("tabindex"), 0, "menu tabindex" );
equals( ul.attr("aria-activedescendant"), links.eq(element[0].selectedIndex).attr("id"), "menu aria-activedescendant" );
equals( button.attr("role"), "combobox", "button link role" );
equals( button.attr("aria-haspopup"), "true", "button link aria-haspopup" );
equals( button.attr("aria-expanded"), "false", "button link aria-expanded" );
equals( button.attr("aria-autocomplete"), "list", "button link aria-autocomplete" );
equals( button.attr("aria-owns"), menu.attr("id"), "button link aria-owns" );
equals( button.attr("tabindex"), 0, "button link tabindex" );

equals( menu.attr("role"), "listbox", "menu role" );
equals( menu.attr("aria-labelledby"), button.attr("id"), "menu aria-labelledby" );
equals( menu.attr("aria-hidden"), "true", "menu aria-hidden" );
equals( menu.attr("tabindex"), 0, "menu tabindex" );
equals( menu.attr("aria-activedescendant"), links.eq(element[0].selectedIndex).attr("id"), "menu aria-activedescendant" );
$.each( links, function(index){
equals( $(this).attr("role"), "option", "menu link #" + index +" role" );
equals( $(this).attr("tabindex"), -1, "menu link #" + index +" tabindex" );
@@ -49,39 +47,26 @@ $.each([
expect(8);

var element = $(settings.selector).selectmenu(),
button = element.selectmenu("widget").parent(),
menu = element.selectmenu("menuWidget").parent(),
link = button.find("a"),
ul = menu.children("ul"),
button = element.selectmenu("widget"),
menu = element.selectmenu("menuWidget"),
selected = element.find("option:selected");

link.simulate( "focus" )
var links = ul.find("li.ui-menu-item a");
button.simulate( "focus" )
var links = menu.find("li.ui-menu-item a");

link.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equals( ul.attr("aria-activedescendant"), links.eq(element[0].selectedIndex).attr("id"), "after keydown menu aria-activedescendant" );
button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equals( menu.attr("aria-activedescendant"), links.eq(element[0].selectedIndex).attr("id"), "after keydown menu aria-activedescendant" );
equals( links.eq(element[0].selectedIndex).attr("aria-selected"), "true", "after keydown selected menu link aria-selected" );
equals( element.find("option:selected").val(), selected.next("option").val() , "after keydown original select state" );
equals( button.text(), selected.next("option").text(), "after keydown button text" );

link.simulate( "click" );
button.simulate( "click" );
menu.find("a").last().simulate( "mouseover" ).trigger( "click" );
equals( ul.attr("aria-activedescendant"), links.eq(element[0].selectedIndex).attr("id"), "after click menu aria-activedescendant" );
equals( menu.attr("aria-activedescendant"), links.eq(element[0].selectedIndex).attr("id"), "after click menu aria-activedescendant" );
equals( links.eq(element[0].selectedIndex).attr("aria-selected"), "true", "after click selected menu link aria-selected" );
equals( element.find("option:selected").val(), element.find("option").last().val(), "after click original select state" );
equals( button.text(), element.find("option").last().text(), "after click button text" );
});
});


// test("mass", function () {
// for (var i = 0; i < 100; i++) {
// var element = $('#speed').selectmenu();
// var widget = element.selectmenu("destroy");
// expect(0);
// }
// });



})( jQuery );
@@ -32,8 +32,7 @@ test("enable / disable", function () {

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

element.selectmenu("disable");
ok( element.selectmenu("option", "disabled"), "disable: widget option" );

0 comments on commit afcdd6a

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