diff options
Diffstat (limited to 'tests/unit/menu')
-rw-r--r-- | tests/unit/menu/menu.html | 74 | ||||
-rw-r--r-- | tests/unit/menu/menu_core.js | 32 | ||||
-rw-r--r-- | tests/unit/menu/menu_defaults.js | 11 | ||||
-rw-r--r-- | tests/unit/menu/menu_events.js | 24 | ||||
-rw-r--r-- | tests/unit/menu/menu_methods.js | 19 | ||||
-rw-r--r-- | tests/unit/menu/menu_options.js | 10 | ||||
-rw-r--r-- | tests/unit/menu/menu_tickets.js | 8 |
7 files changed, 178 insertions, 0 deletions
diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html new file mode 100644 index 000000000..14a5d06db --- /dev/null +++ b/tests/unit/menu/menu.html @@ -0,0 +1,74 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8" /> + <title>jQuery UI Menu Test Suite</title> + + <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" /> + + <script type="text/javascript" src="../../../jquery-1.4.2.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> + <script type="text/javascript" src="../../../external/qunit.js"></script> + <script type="text/javascript" src="../../jquery.simulate.js"></script> + <script type="text/javascript" src="../testsuite.js"></script> + + <script type="text/javascript"> + + function log(message,clear) { + if (clear && clear === true) { + $("#log").html(""); + } + if ( message === undefined ) { + message = $("#log").data("lastItem"); + } + $("#log").prepend( message + "," ); + } + function clickMenu(menu,item) { + $("#log").data("lastItem",item); + $('li:eq(' + item + ') a',menu).trigger("click"); + } + + + </script> + <script type="text/javascript" src="menu_core.js"></script> + <script type="text/javascript" src="menu_defaults.js"></script> + <script type="text/javascript" src="menu_events.js"></script> + <script type="text/javascript" src="menu_methods.js"></script> + <script type="text/javascript" src="menu_options.js"></script> + <script type="text/javascript" src="menu_tickets.js"></script> + + + <style> + #main { font-size: 10pt; font-family: 'trebuchet ms', verdana, arial; } + #list, #list1 *, #navigation, #navigation * { margin: 0; padding: 0; font-size: 12px; } + .mainOnMoon {position: absolute; top: -10000px; left: -10000px;} + </style> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Menu Test Suite</h1> +<h2 id="qunit-banner"></h2> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"> +</ol> + + +<div id="main" class="mainOnMoon"> + +<ul id="menu1"> + <li><a href="#">Aberdeen</a></li> + <li><a href="#">Ada</a></li> + <li><a href="#">Adamsville</a></li> + <li><a href="#">Addyston</a></li> + <li><a href="#">Adelphi</a></li> +</ul> +<div id="log"></div> + +</div> + +</body> +</html> diff --git a/tests/unit/menu/menu_core.js b/tests/unit/menu/menu_core.js new file mode 100644 index 000000000..a1cf11b7f --- /dev/null +++ b/tests/unit/menu/menu_core.js @@ -0,0 +1,32 @@ +/* + * menu_core.js + */ + + +(function($) { + +module("menu: core"); + +test("accessibility", function () { + expect(3); + 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"), "listbox", "main role"); + equals( ac.attr("aria-activedescendant"), "ui-active-menuitem", "aria attribute"); +}); + +test("items class and role", function () { + var ac = $('#menu1').menu(); + expect(1 + 4 * $("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"), "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); diff --git a/tests/unit/menu/menu_defaults.js b/tests/unit/menu/menu_defaults.js new file mode 100644 index 000000000..c3f741d2a --- /dev/null +++ b/tests/unit/menu/menu_defaults.js @@ -0,0 +1,11 @@ +/* + * menu_defaults.js + */ + +var menu_defaults = { + disabled: false, + navigationFilter: function() {} + +}; + +commonWidgetTests('menu', { defaults: menu_defaults }); diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js new file mode 100644 index 000000000..a03bec3f6 --- /dev/null +++ b/tests/unit/menu/menu_events.js @@ -0,0 +1,24 @@ +/* + * menu_events.js + */ +(function($) { + +module("menu: events"); + +test("handle click on menu", function() { + expect(1); + var ac = $('#menu1').menu({ + select: function(event, ui) { + log(); + } + }); + log("click",true); + clickMenu($('#menu1'),"1"); + log("afterclick"); + clickMenu( ac,"2"); + clickMenu($('#menu1'),"3"); + clickMenu( ac,"1"); + equals( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid."); +}); + +})(jQuery); diff --git a/tests/unit/menu/menu_methods.js b/tests/unit/menu/menu_methods.js new file mode 100644 index 000000000..b6ebaf215 --- /dev/null +++ b/tests/unit/menu/menu_methods.js @@ -0,0 +1,19 @@ +/* + * menu_methods.js + */ +(function($) { + +module("menu: methods"); + +test("destroy", function() { + var beforeHtml = $("#menu1").find("div").css("font-style", "normal").end().parent().html(); + var afterHtml = $("#menu1").menu().menu("destroy").parent().html(); + // Opera 9 outputs role="" instead of removing the attribute like everyone else + if ($.browser.opera) { + afterHtml = afterHtml.replace(/ role=""/g, ""); + } + equal( afterHtml, beforeHtml ); +}); + + +})(jQuery); diff --git a/tests/unit/menu/menu_options.js b/tests/unit/menu/menu_options.js new file mode 100644 index 000000000..03822fd74 --- /dev/null +++ b/tests/unit/menu/menu_options.js @@ -0,0 +1,10 @@ +/* + * menu_options.js + */ +(function($) { + +module("menu: options"); + + + +})(jQuery); diff --git a/tests/unit/menu/menu_tickets.js b/tests/unit/menu/menu_tickets.js new file mode 100644 index 000000000..760afd368 --- /dev/null +++ b/tests/unit/menu/menu_tickets.js @@ -0,0 +1,8 @@ +/* + * menu_tickets.js + */ +(function($) { + +module("menu: tickets"); + +})(jQuery); |