Skip to content
Browse files

Selectmenu: added basic markup and a11y unit tests

  • Loading branch information...
1 parent ce3e7c0 commit 26603de5bafb4fe9e824b28d8f799ed0f7e0604f @fnagel fnagel committed
Showing with 42 additions and 4 deletions.
  1. +4 −4 tests/unit/selectmenu/selectmenu.html
  2. +38 −0 tests/unit/selectmenu/selectmenu_core.js
View
8 tests/unit/selectmenu/selectmenu.html
@@ -4,12 +4,12 @@
<meta charset="utf-8">
<title>jQuery UI Selectmenu Test Suite</title>
- <link rel="stylesheet" href="../../../themes/base/jquery.ui.spinner.css">
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.core.css">
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.button.css">
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.menu.css">
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.selectmenu.css">
<script src="../../jquery.js"></script>
- <script src="../../../external/jquery.mousewheel-3.0.4.js"></script>
- <script src="../../../external/globalize.js"></script>
- <script src="../../../external/globalize.culture.ja-JP.js"></script>
<script src="../../../ui/jquery.ui.core.js"></script>
<script src="../../../ui/jquery.ui.widget.js"></script>
<script src="../../../ui/jquery.ui.button.js"></script>
View
38 tests/unit/selectmenu/selectmenu_core.js
@@ -3,4 +3,42 @@
module( "selectmenu: core" );
+test("markup structure", function () {
+ expect(5);
+ var element = $('#speed').selectmenu();
+ var widget = element.selectmenu("widget");
+ var button = widget.filter(".ui-selectmenu-button");
+ var menu = widget.filter(".ui-selectmenu-menu");
+
+ equals( button.length, 1, "button wrapper found");
+ equals( button.children("a").length, 1, "button link found");
+
+ equals( menu.length, 1, "menu wrapper found");
+ equals( menu.children("ul").length, 1, "menu found");
+
+ equals( menu.find("ul li.ui-menu-item").length, element.find("option").length, "menu li's found");
+});
+
+test("accessibility", function () {
+ var element = $('#speed').selectmenu();
+ var widget = element.selectmenu("widget");
+ var button = widget.filter(".ui-selectmenu-button");
+ var menu = widget.filter(".ui-selectmenu-menu");
+ var link = button.children("a");
+ var ul = menu.children("ul")
+ var links = ul.find("li.ui-menu-item a");
+ expect(6 + links.length);
+
+ equals( button.attr("aria-disabled"), "false", "button aria-disabled");
+ equals( link.attr("aria-disabled"), "false", "button link aria-disabled");
+ equals( link.attr("aria-haspopup"), "true", "button link aria-haspopup");
+ equals( link.attr("role"), "button", "button link role");
+ equals( link.attr("aria-owns"), ul.attr("id"), "button link aria-owns");
+ equals( link.attr("tabindex"), 0, "button link tabindex");
+
+ $.each( links, function(index){
+ equals( $(this).attr("role"), "option", "menu link #" + index +" role");
+ });
+});
+
})( jQuery );

0 comments on commit 26603de

Please sign in to comment.
Something went wrong with that request. Please try again.