Selectmenu: updated options and events unit tests

This commit is contained in:
Dan Wellman 2011-12-12 23:39:06 +00:00
parent 041de0716c
commit c1c0827c67
2 changed files with 23 additions and 8 deletions

View File

@ -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 () {

View File

@ -14,8 +14,21 @@
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");
});
@ -23,9 +36,11 @@
test("value option", function () {
expect(1);
this.element.selectmenu("option", "value", "jQuery UI");
var value = this.element.find("option").eq(0).text();
equals(this.element.selectmenu("option", "value"), "jQuery UI", "should be set to 'jQuery UI'");
this.element.selectmenu("option", "value", value);
equals(this.element.selectmenu("option", "value"), value, "should be set to " + value);
});
})(jQuery);