Skip to content
Browse files

Selectmenu: adjust and improve unit tests

  • Loading branch information...
1 parent c5efdda commit e9a35319d46f4d45edab3dcbfb8cf8aa8152d330 @fnagel fnagel committed Feb 26, 2012
Showing with 30 additions and 25 deletions.
  1. +5 −6 tests/unit/selectmenu/selectmenu_methods.js
  2. +25 −19 tests/unit/selectmenu/selectmenu_options.js
View
11 tests/unit/selectmenu/selectmenu_methods.js
@@ -14,16 +14,15 @@ test( "open / close", function() {
expect( 4 );
var element = $('#speed').selectmenu(),
- button = element.selectmenu("widget").parent(),
- menu = element.selectmenu("menuWidget").parent();
+ menu = element.selectmenu("menuWidget");
element.selectmenu("open");
- ok( menu.is( ":visible" ), "menu visible" );
- equals( menu.find("ul").attr("aria-hidden"), "false", "menu aria-disabled" );
+ ok( menu.is( ":visible" ), "open: menu visible" );
+ equals( menu.attr("aria-hidden"), "false", "open: menu aria-disabled" );
element.selectmenu("close");
- ok( menu.is( ":hidden" ), "menu hidden" );
- equals( menu.find("ul").attr("aria-hidden"), "true", "menu aria-disabled" );
+ ok( menu.is( ":hidden" ), "close: menu hidden" );
+ equals( menu.attr("aria-hidden"), "true", "close: menu aria-disabled" );
});
View
44 tests/unit/selectmenu/selectmenu_options.js
@@ -1,35 +1,41 @@
(function ($) {
-module("selectmenu: options", {
- setup: function () {
- this.element = $("#speed").selectmenu();
- }
-});
+module("selectmenu: options");
test("appendTo another element", function () {
expect(2);
-
- ok(this.element.selectmenu("option", "appendTo", "#qunit-fixture"), "appendTo accepts selector");
+
+ element = $("#speed").selectmenu();
+
+ ok(element.selectmenu("option", "appendTo", "#qunit-fixture"), "appendTo accepts selector");
ok($("#qunit-fixture").find(".ui-selectmenu-menu").length, "selectmenu appendedTo other element");
});
test("dropdown: CSS styles", function () {
- expect(4);
+ expect(2);
+
+ var element = $("#speed").selectmenu(),
+ button = element.selectmenu("widget"),
+ menu = element.selectmenu("menuWidget");
- var button = this.element.selectmenu("widget").parent(),
- ul = this.element.selectmenu("menuWidget"),
- link = button.find("a");
+ element.selectmenu("open");
+ ok( button.hasClass("ui-corner-top") && !button.hasClass("ui-corner-all") && button.find("span.ui-icon").hasClass("ui-icon-triangle-1-s"), "button styles dropdown");
+ ok( menu.hasClass("ui-corner-bottom") && !menu.hasClass("ui-corner-all"), "menu styles dropdown");
+});
+
+test("pop-up: CSS styles", function () {
+ expect(2);
- this.element.selectmenu("open");
- ok( link.hasClass("ui-corner-top") && !link.hasClass("ui-corner-all"), "button styles dropdown");
- ok( ul.hasClass("ui-corner-bottom") && !ul.hasClass("ui-corner-all"), "menu styles dropdown");
+ var element = $("#speed").selectmenu({
+ dropdown: false
+ }),
+ button = element.selectmenu("widget"),
+ menu = element.selectmenu("menuWidget");
- this.element.selectmenu("close");
- this.element.selectmenu("option", "dropdown", false);
- this.element.selectmenu("open");
- ok( !link.hasClass("ui-corner-top") && link.hasClass("ui-corner-all"), "button styles pop-up");
- ok( !ul.hasClass("ui-corner-bottom") && ul.hasClass("ui-corner-all"), "menu styles pop-up");
+ element.selectmenu("close");
+ ok( !button.hasClass("ui-corner-top") && button.hasClass("ui-corner-all") && button.find("span.ui-icon").hasClass("ui-icon-triangle-2-n-s"), "button styles pop-up");
+ ok( !menu.hasClass("ui-corner-bottom") && menu.hasClass("ui-corner-all"), "menu styles pop-up");
});
})(jQuery);

0 comments on commit e9a3531

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