aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/selectmenu
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2012-01-12 22:04:43 +0100
committerFelix Nagel <info@felixnagel.com>2012-01-12 22:04:43 +0100
commit70ba3b991ed546cd80451ee7e6fb213cac89699b (patch)
treeb750301f47621e24819d3fa12812289ab006499d /tests/unit/selectmenu
parent3369ec340d302ff37f1a8bb52d26a2d270c28596 (diff)
downloadjquery-ui-70ba3b991ed546cd80451ee7e6fb213cac89699b.tar.gz
jquery-ui-70ba3b991ed546cd80451ee7e6fb213cac89699b.zip
Selectmenu: fixed unit tests, needs additional check and cleanup
Diffstat (limited to 'tests/unit/selectmenu')
-rw-r--r--tests/unit/selectmenu/selectmenu_core.js51
-rw-r--r--tests/unit/selectmenu/selectmenu_events.js14
2 files changed, 34 insertions, 31 deletions
diff --git a/tests/unit/selectmenu/selectmenu_core.js b/tests/unit/selectmenu/selectmenu_core.js
index dea3f5d8a..76c0ab18f 100644
--- a/tests/unit/selectmenu/selectmenu_core.js
+++ b/tests/unit/selectmenu/selectmenu_core.js
@@ -10,24 +10,21 @@ test("accessibility", function () {
var link = button.children("a");
var ul = menu.children("ul")
var links = ul.find("li.ui-menu-item a");
- expect(12 + links.length * 2);
-
- 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" );
+ expect(9 + links.length * 2);
- equals( ul.attr("aria-hidden"), "true", "menu aria-hidden" );
- equals( ul.attr("aria-disabled"), "false", "menu aria-disabled" );
- equals( ul.attr("aria-labelledby"), link.attr("id"), "menu aria-labelledby" );
- equals( ul.attr("role"), "menubox", "menu role" );
- equals( ul.attr("tabindex"), 0, "menu tabindex" );
- equals( ul.attr("aria-activedescendant"), links.eq(element[0].selectedIndex).attr("id"), "menu aria-activedescendant" );
+ equals( "true", link.attr("aria-haspopup"), "button link aria-haspopup" );
+ equals( "button", link.attr("role"), "button link role" );
+ equals( ul.attr("id"), link.attr("aria-owns"), "button link aria-owns" );
+ equals( 0, link.attr("tabindex"), "button link tabindex" );
+
+ equals( "true", ul.attr("aria-hidden"), "menu aria-hidden" );
+ equals( link.attr("id"), ul.attr("aria-labelledby"), "menu aria-labelledby" );
+ equals( "menubox", ul.attr("role"), "menu role" );
+ equals( 0, ul.attr("tabindex"), "menu tabindex" );
+ equals( links.eq(element[0].selectedIndex).attr("id"), ul.attr("aria-activedescendant"), "menu aria-activedescendant" );
$.each( links, function(index){
- equals( $(this).attr("role"), "option", "menu link #" + index +" role" );
- equals( $(this).attr("tabindex"), -1, "menu link #" + index +" tabindex" );
+ equals( "option", $(this).attr("role"), "menu link #" + index +" role" );
+ equals( -1, $(this).attr("tabindex"), "menu link #" + index +" tabindex" );
});
});
@@ -43,24 +40,26 @@ $.each([
}
], function( i, settings ) {
test("state synchronization - " + settings.type, function () {
- expect(6);
+ expect(5);
var element = $(settings.selector).selectmenu();
var widget = element.selectmenu("widget");
var button = widget.filter(".ui-selectmenu-button");
var menu = widget.filter(".ui-selectmenu-menu");
+ var link = button.find("a");
+ var selected = element.find("option:selected");
- equals( element[0].value, element.selectmenu("option", "value"), "inital value" );
- equals( element.find("option:selected").text(), button.text(), "inital button text" );
+ equals( button.text(), selected.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" );
+ link.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ equals( element.find("option:selected").val(), selected.next("option").val() , "after keydown original select state" );
+ equals( button.text(), selected.next("option").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" );
+ link.simulate( "click" );
+ menu.find("a").last().simulate( "mouseover" ).simulate( "click" );
+ equals( element.find("option:selected").val(), element.find("option").last().val(), "after click original select state" );
+ equals( button.text(), element.find("option").last().text(), "after click button text" );
});
});
+
})( jQuery );
diff --git a/tests/unit/selectmenu/selectmenu_events.js b/tests/unit/selectmenu/selectmenu_events.js
index fa25e69bb..65e12eab4 100644
--- a/tests/unit/selectmenu/selectmenu_events.js
+++ b/tests/unit/selectmenu/selectmenu_events.js
@@ -21,11 +21,11 @@
var widget = this.element.selectmenu("widget"),
menu = widget.filter(".ui-selectmenu-menu"),
- value = this.element.find("option").eq(0).text();
+ button = widget.filter(".ui-selectmenu-button"),
+ value = this.element.find("option").first().text();
- menu.find(".ui-menu-item").eq(0).simulate("click");
-
- equals(this.element.selectmenu("option", "value"), "Slower", "should be set to first option");
+ button.find("a").simulate( "click" );
+ menu.find("a").first().simulate( "mouseover" ).simulate( "click" );
});
test("close", function () {
@@ -61,8 +61,10 @@
});
var widget = this.element.selectmenu("widget"),
+ button = widget.filter(".ui-selectmenu-button"),
menu = widget.filter(".ui-selectmenu-menu");
+ button.find("a").simulate( "click" );
menu.find(".ui-menu-item").simulate("mouseover");
});
@@ -93,9 +95,11 @@
});
var widget = this.element.selectmenu("widget"),
+ button = widget.filter(".ui-selectmenu-button"),
menu = widget.filter(".ui-selectmenu-menu");
- menu.find(".ui-menu-item").eq(0).simulate("click");
+ button.find("a").simulate( "click" );
+ menu.find("a").first().simulate( "mouseover" ).simulate("click");
});
})(jQuery);