Skip to content
Permalink
Browse files

Selectmenu: added basic method unit tests

  • Loading branch information
fnagel committed Nov 21, 2011
1 parent e79700e commit d97b6db2cdcc2adf88381c3d7a7d733ea51fab71
@@ -37,7 +37,7 @@ <h2 id="qunit-banner"></h2>
<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 @@ <h2 id="qunit-userAgent"></h2>
<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>
@@ -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 () {
@@ -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 );

0 comments on commit d97b6db

Please sign in to comment.
You can’t perform that action at this time.