Skip to content
Permalink
Browse files

Selectmenu: updated options and events unit tests

  • Loading branch information
danwellman committed Dec 12, 2011
1 parent 041de07 commit c1c0827c67de6d52936d7b1906051ab7be95827b
Showing with 23 additions and 8 deletions.
  1. +4 −4 tests/unit/selectmenu/selectmenu_events.js
  2. +19 −4 tests/unit/selectmenu/selectmenu_options.js
@@ -14,16 +14,16 @@
ok(event, "change event fired on change");
equals(event.type, "selectmenuchange", "event type set to selectmenuchange");
ok(ui, "ui object is passed as second argument to event handler");
equals(ui.item.element[0].nodeName, "OPTION", "ui points to original option element");
equals(ui.item.element[0].nodeName, "OPTION", "ui.item.element[0] points to original option element");
equals(ui.item.value, value, "ui.item.value property updated correctly");
}
});

var widget = this.element.selectmenu("widget"),
menu = widget.filter(".ui-selectmenu-menu");
menu = widget.filter(".ui-selectmenu-menu"),
value = this.element.find("option").eq(0).text();

menu.find(".ui-menu-item").eq(0).simulate("click");

equals(this.element.selectmenu("option", "value"), "Slower", "should be set to first option");
});

test("close", function () {
@@ -14,18 +14,33 @@
ok($("#qunit-fixture").find(".ui-selectmenu-menu").length, "selectmenu appendedTo other element");
});

test("dropdown false", function () {
expect(1);
test("dropdown", function () {
expect(2);

var button = $("#speed-button"),
widget = this.element.selectmenu("widget"),
buttonPos = {
l: button.offset().top,
t: button.offset().left
},
menuPos = {
l: widget.offset().top,
t: widget.offset().left
};

equals(menuPos.t, buttonPos.t, "menu positioned below button in dropdown mode"); //button has no height

ok(this.element.selectmenu("option", "dropdown", false), "accepts false");
});

test("value option", function () {
expect(1);

this.element.selectmenu("option", "value", "jQuery UI");
var value = this.element.find("option").eq(0).text();

this.element.selectmenu("option", "value", value);

equals(this.element.selectmenu("option", "value"), "jQuery UI", "should be set to 'jQuery UI'");
equals(this.element.selectmenu("option", "value"), value, "should be set to " + value);
});

})(jQuery);

0 comments on commit c1c0827

Please sign in to comment.
You can’t perform that action at this time.