aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/menu/menu_core.js
blob: c0feae75c7728ba80703fe4e68ab50d6f9e29a6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * menu_core.js
 */


(function($) {

module("menu: core");

test("accessibility", function () {
	expect(5);
	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");
	equals( ac.attr("role"), "menu", "main role");
	ok( !ac.attr("aria-activedescendant"), "aria attribute not yet active");

	var item = ac.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end();
	ac.menu( "focus", $.Event(), item );
	equals( ac.attr("aria-activedescendant"), "xid", "aria attribute, id from dom");

	var item = ac.find( "li:last" );
	ac.menu( "focus", $.Event(), item );
	equals( ac.attr("aria-activedescendant"), "menu1-4", "aria attribute, generated id");
});

test("items class and role", function () {
	var ac = $('#menu1').menu();
	expect(1 + 5 * $("li",ac).length);
	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");
		equals( $(this).attr("role"), "presentation", "menu item ("+ item + ") role");
		equals( $("a", this).attr("role"), "menuitem", "menu item ("+ item + ") role");
		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);