2011-10-19 17:47:02 +00:00
|
|
|
(function( $ ) {
|
|
|
|
|
|
|
|
module( "selectmenu: core" );
|
|
|
|
|
2011-11-02 20:56:37 +00:00
|
|
|
test("accessibility", function () {
|
|
|
|
var element = $('#speed').selectmenu();
|
|
|
|
var widget = element.selectmenu("widget");
|
|
|
|
var button = widget.filter(".ui-selectmenu-button");
|
|
|
|
var menu = widget.filter(".ui-selectmenu-menu");
|
|
|
|
var link = button.children("a");
|
|
|
|
var ul = menu.children("ul")
|
|
|
|
var links = ul.find("li.ui-menu-item a");
|
|
|
|
expect(6 + links.length);
|
|
|
|
|
2011-11-21 20:54:04 +00:00
|
|
|
equals( button.attr("aria-disabled"), "false", "button aria-disabled" );
|
|
|
|
equals( link.attr("aria-disabled"), "false", "button link aria-disabled" );
|
|
|
|
equals( link.attr("aria-haspopup"), "true", "button link aria-haspopup" );
|
|
|
|
equals( link.attr("role"), "button", "button link role" );
|
|
|
|
equals( link.attr("aria-owns"), ul.attr("id"), "button link aria-owns" );
|
|
|
|
equals( link.attr("tabindex"), 0, "button link tabindex" );
|
2011-11-02 20:56:37 +00:00
|
|
|
|
|
|
|
$.each( links, function(index){
|
2011-11-21 20:54:04 +00:00
|
|
|
equals( $(this).attr("role"), "option", "menu link #" + index +" role" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$.each([
|
|
|
|
{
|
|
|
|
type: "default",
|
2011-11-21 23:35:27 +00:00
|
|
|
selector: "#speed"
|
2011-11-21 20:54:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "optgroups",
|
2011-11-21 23:35:27 +00:00
|
|
|
selector: "#files"
|
2011-11-21 20:54:04 +00:00
|
|
|
}
|
|
|
|
], function( i, settings ) {
|
|
|
|
test("state synchronization - " + settings.type, function () {
|
|
|
|
expect(6);
|
|
|
|
var element = $(settings.selector).selectmenu();
|
|
|
|
var widget = element.selectmenu("widget");
|
|
|
|
var button = widget.filter(".ui-selectmenu-button");
|
|
|
|
var menu = widget.filter(".ui-selectmenu-menu");
|
|
|
|
|
|
|
|
equals( element[0].value, element.selectmenu("option", "value"), "inital value" );
|
|
|
|
equals( element.find("option:selected").text(), button.text(), "inital button text" );
|
|
|
|
|
|
|
|
button.find("a").simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
|
|
|
equals( element[0].value, element.selectmenu("option", "value"), "after keydown value" );
|
|
|
|
equals( element.find("option:selected").text(), button.text(), "after keydown button text" );
|
|
|
|
|
|
|
|
button.find("a").simulate( "click" );
|
|
|
|
menu.find("a").last().simulate( "click" );
|
|
|
|
equals( element[0].value, element.selectmenu("option", "value"), "after click value" );
|
|
|
|
equals( element.find("option:selected").text(), button.text(), "after click button text" );
|
2011-11-02 20:56:37 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2011-10-19 17:47:02 +00:00
|
|
|
})( jQuery );
|