2010-05-06 15:10:52 +00:00
|
|
|
/*
|
|
|
|
* menu_core.js
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
module("menu: core");
|
|
|
|
|
|
|
|
test("accessibility", function () {
|
2011-02-11 14:42:44 +00:00
|
|
|
expect(5);
|
2012-04-19 13:39:21 +00:00
|
|
|
var item,
|
|
|
|
menu = $('#menu1').menu(),
|
|
|
|
item0 = $("li:eq(0) a");
|
2010-05-06 15:10:52 +00:00
|
|
|
|
2012-01-22 17:26:41 +00:00
|
|
|
ok( menu.hasClass("ui-menu ui-widget ui-widget-content ui-corner-all"), "menu class");
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( menu.attr("role"), "menu", "main role");
|
2012-01-22 17:26:41 +00:00
|
|
|
ok( !menu.attr("aria-activedescendant"), "aria attribute not yet active");
|
2011-05-02 18:35:58 +00:00
|
|
|
|
2012-04-19 13:39:21 +00:00
|
|
|
item = menu.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end();
|
2012-01-22 17:26:41 +00:00
|
|
|
menu.menu( "focus", $.Event(), item );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( menu.attr("aria-activedescendant"), "xid", "aria attribute, id from dom");
|
2011-05-02 18:35:58 +00:00
|
|
|
|
2012-04-19 13:39:21 +00:00
|
|
|
item = menu.find( "li:last" );
|
2012-01-22 17:26:41 +00:00
|
|
|
menu.menu( "focus", $.Event(), item );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( menu.attr("aria-activedescendant"), "menu1-4", "aria attribute, generated id");
|
2010-05-06 15:10:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("items class and role", function () {
|
2012-01-22 17:26:41 +00:00
|
|
|
var menu = $('#menu1').menu();
|
|
|
|
expect(1 + 5 * $("li",menu).length);
|
|
|
|
ok( ($("li",menu).length > 0 ), "number of menu items");
|
|
|
|
$("li",menu).each(function(item) {
|
2010-05-06 15:10:52 +00:00
|
|
|
ok( $(this).hasClass("ui-menu-item"), "menu item ("+ item + ") class for item");
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( $(this).attr("role"), "presentation", "menu item ("+ item + ") role");
|
|
|
|
equal( $("a", this).attr("role"), "menuitem", "menu item ("+ item + ") role");
|
2010-05-06 15:10:52 +00:00
|
|
|
ok( $("a",this).hasClass("ui-corner-all"), "a element class for menu item ("+ item + ") ");
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( $("a",this).attr("tabindex"), "-1", "a element tabindex for menu item ("+ item + ") ");
|
2010-05-06 15:10:52 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
})(jQuery);
|