aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/selectmenu
diff options
context:
space:
mode:
authorDan Wellman <danwellman@hotmail.com>2011-11-24 15:50:20 +0000
committerDan Wellman <danwellman@hotmail.com>2011-11-24 15:50:20 +0000
commit63d77ae477761b60b1290f01a6dfbe12a2a71170 (patch)
tree65cc3163ea1fa116c1edfaec048b71deeadea585 /tests/unit/selectmenu
parentd97b6db2cdcc2adf88381c3d7a7d733ea51fab71 (diff)
downloadjquery-ui-63d77ae477761b60b1290f01a6dfbe12a2a71170.tar.gz
jquery-ui-63d77ae477761b60b1290f01a6dfbe12a2a71170.zip
Selectmenu: Added event unit tests
Diffstat (limited to 'tests/unit/selectmenu')
-rw-r--r--tests/unit/selectmenu/selectmenu_events.js108
1 files changed, 105 insertions, 3 deletions
diff --git a/tests/unit/selectmenu/selectmenu_events.js b/tests/unit/selectmenu/selectmenu_events.js
index 888ab9e9b..2694eaf7f 100644
--- a/tests/unit/selectmenu/selectmenu_events.js
+++ b/tests/unit/selectmenu/selectmenu_events.js
@@ -1,7 +1,109 @@
-(function( $ ) {
+(function ($) {
-module( "selectmenu: events" );
+ module("selectmenu: events", {
+ setup: function () {
+ this.element = $("#speed");
+ }
+ });
+ test("change", function () {
+ expect(4);
+ var counter = 0;
-})( jQuery );
+ 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");
+ }
+ }
+ });
+
+ var widget = this.element.selectmenu("widget"),
+ menu = widget.filter(".ui-selectmenu-menu");
+
+ menu.find(".ui-menu-item").simulate("click");
+ });
+
+ test("close", function () {
+ expect(3);
+
+ this.element.selectmenu({
+ close: function (event, ui) {
+ ok(event, "close event fired on close");
+ equals(event.type, "selectmenuclose", "event type set to selectmenuclose");
+ ok(ui, "ui object is passed as second argument to event handler");
+ }
+ });
+
+ this.element.selectmenu("open").selectmenu("close");
+ });
+
+ test("focus", function () {
+ expect(4);
+
+ var counter = 0;
+
+ this.element.selectmenu({
+ focus: function (event, ui) {
+ counter++;
+
+ if (counter === 1) {
+ ok(event, "focus event fired on mouseover");
+ equals(event.type, "selectmenufocus", "event type set to selectmenufocus");
+ 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("mouseover");
+ });
+
+ test("open", function () {
+ expect(3);
+
+ this.element.selectmenu({
+ open: function (event, ui) {
+ ok(event, "open event fired on open");
+ equals(event.type, "selectmenuopen", "event type set to selectmenuopen");
+ ok(ui, "ui object is passed as second argument to event handler");
+ }
+ });
+
+ this.element.selectmenu("open");
+ });
+
+ 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");
+ }
+ }
+ });
+
+ var widget = this.element.selectmenu("widget"),
+ menu = widget.filter(".ui-selectmenu-menu");
+
+ menu.find(".ui-menu-item").simulate("click");
+ });
+
+})(jQuery);