Permalink
Browse files

Selectmenu: added state synchronization unit test

  • Loading branch information...
1 parent 0d064bb commit 74b8a504bcddd35972f1a32ebdb7fd3fd47d1924 @fnagel fnagel committed Nov 21, 2011
Showing with 41 additions and 7 deletions.
  1. +41 −7 tests/unit/selectmenu/selectmenu_core.js
@@ -12,15 +12,49 @@ test("accessibility", function () {
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");
+ 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");
+ equals( $(this).attr("role"), "option", "menu link #" + index +" role" );
+ });
+});
+
+
+$.each([
+ {
+ type: "default",
+ selector: "#speed",
+ valueMethod: "val"
+ },
+ {
+ type: "optgroups",
+ selector: "#files",
+ valueMethod: "text"
+ }
+], function( i, settings ) {
+ test("state synchronization - " + settings.type, function () {
+ expect(6);
+ var element = $(settings.selector).selectmenu();
+ var widget = element.selectmenu("widget");
+ var button = widget.filter(".ui-selectmenu-button");
+ var menu = widget.filter(".ui-selectmenu-menu");
+
+ equals( element[0].value, element.selectmenu("option", "value"), "inital value" );
+ equals( element.find("option:selected").text(), button.text(), "inital button text" );
+
+ button.find("a").simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ equals( element[0].value, element.selectmenu("option", "value"), "after keydown value" );
+ equals( element.find("option:selected").text(), button.text(), "after keydown button text" );
+
+ button.find("a").simulate( "click" );
+ menu.find("a").last().simulate( "click" );
+ equals( element[0].value, element.selectmenu("option", "value"), "after click value" );
+ equals( element.find("option:selected").text(), button.text(), "after click button text" );
});
});

0 comments on commit 74b8a50

Please sign in to comment.