Selectmenu: cleanup unit tests, removing mass test

This commit is contained in:
Felix Nagel 2012-02-22 00:09:44 +01:00
parent 45263578dd
commit afcdd6a75c
2 changed files with 25 additions and 41 deletions

View File

@ -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( 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( 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( 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 );

View File

@ -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" );