Skip to content

Commit

Permalink
Updates to events and options unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danwellman committed Dec 1, 2011
1 parent a4fd544 commit f381749
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 51 deletions.
32 changes: 10 additions & 22 deletions tests/unit/selectmenu/selectmenu_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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);
29 changes: 0 additions & 29 deletions tests/unit/selectmenu/selectmenu_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit f381749

Please sign in to comment.