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);
|
2010-05-06 15:10:52 +00:00
|
|
|
var ac = $('#menu1').menu();
|
|
|
|
var item0 = $("li:eq(0) a");
|
|
|
|
|
|
|
|
ok( ac.hasClass("ui-menu ui-widget ui-widget-content ui-corner-all"), "menu class");
|
2011-05-02 18:35:58 +00:00
|
|
|
equals( ac.attr("role"), "menu", "main role");
|
2011-02-25 17:58:44 +00:00
|
|
|
ok( !ac.attr("aria-activedescendant"), "aria attribute not yet active");
|
2011-05-02 18:35:58 +00:00
|
|
|
|
2011-02-11 14:42:44 +00:00
|
|
|
var item = ac.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end();
|
2011-02-24 09:07:24 +00:00
|
|
|
ac.menu( "focus", $.Event(), item );
|
2011-02-11 14:42:44 +00:00
|
|
|
equals( ac.attr("aria-activedescendant"), "xid", "aria attribute, id from dom");
|
2011-05-02 18:35:58 +00:00
|
|
|
|
2011-02-11 14:42:44 +00:00
|
|
|
var item = ac.find( "li:last" );
|
2011-02-24 09:07:24 +00:00
|
|
|
ac.menu( "focus", $.Event(), item );
|
2011-05-02 18:35:58 +00:00
|
|
|
equals( ac.attr("aria-activedescendant"), "menu1-4", "aria attribute, generated id");
|
2010-05-06 15:10:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("items class and role", function () {
|
|
|
|
var ac = $('#menu1').menu();
|
2011-05-02 18:35:58 +00:00
|
|
|
expect(1 + 5 * $("li",ac).length);
|
2010-05-06 15:10:52 +00:00
|
|
|
ok( ($("li",ac).length > 0 ), "number of menu items");
|
|
|
|
$("li",ac).each(function(item) {
|
|
|
|
ok( $(this).hasClass("ui-menu-item"), "menu item ("+ item + ") class for item");
|
2011-05-02 18:35:58 +00:00
|
|
|
equals( $(this).attr("role"), "presentation", "menu item ("+ item + ") role");
|
|
|
|
equals( $("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 + ") ");
|
|
|
|
equals( $("a",this).attr("tabindex"), "-1", "a element tabindex for menu item ("+ item + ") ");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
})(jQuery);
|