diff options
author | Dan Wellman <danwellman@hotmail.com> | 2011-11-25 10:32:44 +0000 |
---|---|---|
committer | Dan Wellman <danwellman@hotmail.com> | 2011-11-25 10:32:44 +0000 |
commit | fce4725a8ac599efab5449710550a029a2d6fbe3 (patch) | |
tree | b9f540cccb904ac98627f0a063825075e3b717f7 /tests/unit/selectmenu | |
parent | 63d77ae477761b60b1290f01a6dfbe12a2a71170 (diff) | |
download | jquery-ui-fce4725a8ac599efab5449710550a029a2d6fbe3.tar.gz jquery-ui-fce4725a8ac599efab5449710550a029a2d6fbe3.zip |
Selectmenu: added option unit tests
Diffstat (limited to 'tests/unit/selectmenu')
-rw-r--r-- | tests/unit/selectmenu/selectmenu_options.js | 61 |
1 files changed, 58 insertions, 3 deletions
diff --git a/tests/unit/selectmenu/selectmenu_options.js b/tests/unit/selectmenu/selectmenu_options.js index b19dac4d4..ed6a27bab 100644 --- a/tests/unit/selectmenu/selectmenu_options.js +++ b/tests/unit/selectmenu/selectmenu_options.js @@ -1,7 +1,62 @@ -(function( $ ) { +(function ($) { -module( "selectmenu: options" ); + module("selectmenu: options", { + setup: function () { + this.element = $("#speed"); + this.element.selectmenu(); + } + }); + test("{ appendTo: default }", function () { + expect(1); + equals(this.element.selectmenu("option", "appendTo"), "body", "should be appended to <body> by default"); + }); -})( jQuery ); + 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); + + var widget = this.element.selectmenu("widget"), + menu = widget.filter(".ui-selectmenu-menu"); + + menu.find(".ui-menu-item").eq(0).simulate("click"); + + equals(this.element.selectmenu("option", "value"), "Slower", "should be set to first option"); + }); + +})(jQuery); |