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 @@ + + + + + jQuery UI Menu Test Suite + + + + + + + + + + + + + + + + + + + + + + + + + + +

jQuery UI Menu Test Suite

+

+

+
    +
+ + +
+ + +
+ +
+ + + 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);