mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Updates to events and options unit tests
This commit is contained in:
parent
a4fd5449b2
commit
f381749ed7
@ -9,25 +9,19 @@
|
||||
test("change", function () {
|
||||
expect(4);
|
||||
|
||||
var counter = 0;
|
||||
|
||||
this.element.selectmenu({
|
||||
change: function (event, ui) {
|
||||
counter++;
|
||||
|
||||
if (counter === 1) {
|
||||
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");
|
||||
}
|
||||
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");
|
||||
}
|
||||
});
|
||||
|
||||
var widget = this.element.selectmenu("widget"),
|
||||
menu = widget.filter(".ui-selectmenu-menu");
|
||||
|
||||
menu.find(".ui-menu-item").simulate("click");
|
||||
menu.find(".ui-menu-item").eq(0).simulate("click");
|
||||
});
|
||||
|
||||
test("close", function () {
|
||||
@ -85,25 +79,19 @@
|
||||
test("select", function () {
|
||||
expect(4);
|
||||
|
||||
var counter = 0;
|
||||
|
||||
this.element.selectmenu({
|
||||
select: function (event, ui) {
|
||||
counter++;
|
||||
|
||||
if (counter === 1) {
|
||||
ok(event, "select event fired on item select");
|
||||
equals(event.type, "selectmenuselect", "event type set to selectmenuselect");
|
||||
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");
|
||||
}
|
||||
ok(event, "select event fired on item select");
|
||||
equals(event.type, "selectmenuselect", "event type set to selectmenuselect");
|
||||
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");
|
||||
}
|
||||
});
|
||||
|
||||
var widget = this.element.selectmenu("widget"),
|
||||
menu = widget.filter(".ui-selectmenu-menu");
|
||||
|
||||
menu.find(".ui-menu-item").simulate("click");
|
||||
menu.find(".ui-menu-item").eq(0).simulate("click");
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
@ -7,47 +7,18 @@
|
||||
}
|
||||
});
|
||||
|
||||
test("{ appendTo: default }", function () {
|
||||
expect(1);
|
||||
|
||||
equals(this.element.selectmenu("option", "appendTo"), "body", "should be appended to <body> by default");
|
||||
});
|
||||
|
||||
test("appendTo another element", function () {
|
||||
expect(1);
|
||||
|
||||
ok(this.element.selectmenu("option", "appendTo", "#qunit-fixture"), "appendTo accepts selector");
|
||||
});
|
||||
|
||||
test("{ dropdown: default }", function () {
|
||||
expect(1);
|
||||
|
||||
equals(this.element.selectmenu("option", "dropdown"), true, "should be true by default");
|
||||
});
|
||||
|
||||
test("dropdown false", function () {
|
||||
expect(1);
|
||||
|
||||
ok(this.element.selectmenu("option", "dropdown", false), "accepts false");
|
||||
});
|
||||
|
||||
test("{ position: default }", function () {
|
||||
expect(4);
|
||||
|
||||
var pos = this.element.selectmenu("option", "position");
|
||||
|
||||
ok(typeof (pos) === "object", "position should be of type 'object'");
|
||||
equals(pos.my, "left top", "my should be 'left top' by default");
|
||||
equals(pos.at, "left bottom", "at should be 'left bottom' by default");
|
||||
equals(pos.collision, "none", "collision should be 'none' by default")
|
||||
});
|
||||
|
||||
test("{ value: default }", function () {
|
||||
expect(1);
|
||||
|
||||
equals(this.element.selectmenu("option", "value"), "Medium", "should reflect selected value of underlying select");
|
||||
});
|
||||
|
||||
test("value in sync with selected item", function () {
|
||||
expect(1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user