diff options
author | Felix Nagel <info@felixnagel.com> | 2011-11-22 00:35:27 +0100 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2011-11-22 00:35:27 +0100 |
commit | d97b6db2cdcc2adf88381c3d7a7d733ea51fab71 (patch) | |
tree | 7541d01f19941e224cbf71e45537a94872bf7d42 | |
parent | e79700eb288fd0fdc441311d0ee8c7bb887c8f22 (diff) | |
download | jquery-ui-d97b6db2cdcc2adf88381c3d7a7d733ea51fab71.tar.gz jquery-ui-d97b6db2cdcc2adf88381c3d7a7d733ea51fab71.zip |
Selectmenu: added basic method unit tests
-rw-r--r-- | tests/unit/selectmenu/selectmenu.html | 29 | ||||
-rw-r--r-- | tests/unit/selectmenu/selectmenu_core.js | 6 | ||||
-rw-r--r-- | tests/unit/selectmenu/selectmenu_methods.js | 61 |
3 files changed, 89 insertions, 7 deletions
diff --git a/tests/unit/selectmenu/selectmenu.html b/tests/unit/selectmenu/selectmenu.html index 761b916ee..c64b364fa 100644 --- a/tests/unit/selectmenu/selectmenu.html +++ b/tests/unit/selectmenu/selectmenu.html @@ -37,7 +37,7 @@ <h2 id="qunit-userAgent"></h2> <ol id="qunit-tests"></ol> <div id="qunit-fixture"> - + <label for="speed">Select a speed:</label> <select name="speed" id="speed"> <option value="Slower">Slower</option> @@ -46,10 +46,33 @@ <option value="Fast">Fast</option> <option value="Faster">Faster</option> </select> - + + <label for="number">Select a number:</label> + <select name="number" id="number"> + <option value="1">1</option> + <option value="2" selected="selected">2</option> + <option value="3">3</option> + <option value="4">4</option> + <option value="5">5</option> + <option value="6">6</option> + <option value="7">7</option> + <option value="8">8</option> + <option value="9">9</option> + <option value="10">10</option> + <option value="11">11</option> + <option value="12">12</option> + <option value="13">13</option> + <option value="14">14</option> + <option value="15">15</option> + <option value="16">16</option> + <option value="17">17</option> + <option value="18">18</option> + <option value="19">19</option> + </select> + <label for="files">Select a file:</label> <select name="files" id="files"> - <optgroup disabled="disabled" label="Scripts"> + <optgroup label="Scripts"> <option value="jquery">jQuery.js</option> <option value="jqueryui">ui.jQuery.js</option> </optgroup> diff --git a/tests/unit/selectmenu/selectmenu_core.js b/tests/unit/selectmenu/selectmenu_core.js index 19ab15f0d..e19fefeea 100644 --- a/tests/unit/selectmenu/selectmenu_core.js +++ b/tests/unit/selectmenu/selectmenu_core.js @@ -28,13 +28,11 @@ test("accessibility", function () { $.each([ { type: "default", - selector: "#speed", - valueMethod: "val" + selector: "#speed" }, { type: "optgroups", - selector: "#files", - valueMethod: "text" + selector: "#files" } ], function( i, settings ) { test("state synchronization - " + settings.type, function () { diff --git a/tests/unit/selectmenu/selectmenu_methods.js b/tests/unit/selectmenu/selectmenu_methods.js index a17d2f904..17d5488d6 100644 --- a/tests/unit/selectmenu/selectmenu_methods.js +++ b/tests/unit/selectmenu/selectmenu_methods.js @@ -9,4 +9,65 @@ test( "destroy", function() { }); }); + +test( "open", function() { + expect( 2 ); + + var element = $("#speed").selectmenu(); + var widget = element.selectmenu("widget"); + var button = widget.filter(".ui-selectmenu-button"); + var menu = widget.filter(".ui-selectmenu-menu"); + + element.selectmenu("open"); + ok( menu.is( ":visible" ), "menu visible" ); + equals( menu.find("ul").attr("aria-hidden"), "false", "menu aria-disabled" ); +}); + + +test( "close", function() { + expect( 2 ); + + var element = $("#speed").selectmenu(); + var widget = element.selectmenu("widget"); + var button = widget.filter(".ui-selectmenu-button"); + var menu = widget.filter(".ui-selectmenu-menu"); + + element.selectmenu("open"); + element.selectmenu("close"); + ok( menu.is( ":hidden" ), "menu hidden" ); + equals( menu.find("ul").attr("aria-hidden"), "true", "menu aria-disabled" ); +}); + + +$.each([ + { + type: "default", + selector: "#speed", + options: null + }, + { + type: "pop-up", + selector: "#number", + options: { + dropdown: false + } + }, + { + type: "optgroups", + selector: "#files", + options: null + } +], function( i, settings ) { + test("refresh - " + settings.type, function () { + // expect(6); + var element = $(settings.selector).selectmenu(settings.options); + var widget = element.selectmenu("widget"); + var button = widget.filter(".ui-selectmenu-button"); + var menu = widget.filter(".ui-selectmenu-menu"); + + element.selectmenu("refresh"); + }); +}); + + })( jQuery ); |