mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Selectmenu tests: improve appendTo option tests
This commit is contained in:
parent
930e9d5993
commit
ae68ab8118
@ -37,7 +37,9 @@
|
|||||||
<h2 id="qunit-userAgent"></h2>
|
<h2 id="qunit-userAgent"></h2>
|
||||||
<ol id="qunit-tests"></ol>
|
<ol id="qunit-tests"></ol>
|
||||||
<div id="qunit-fixture">
|
<div id="qunit-fixture">
|
||||||
|
<div id="sm-wrap1" class="sm-wrap"></div>
|
||||||
|
|
||||||
|
<div id="sm-wrap2" class="sm-wrap">
|
||||||
<label for="speed">Select a speed:</label>
|
<label for="speed">Select a speed:</label>
|
||||||
<select name="speed" id="speed">
|
<select name="speed" id="speed">
|
||||||
<option value="Slower">Slower</option>
|
<option value="Slower">Slower</option>
|
||||||
@ -46,6 +48,7 @@
|
|||||||
<option value="Fast">Fast</option>
|
<option value="Fast">Fast</option>
|
||||||
<option value="Faster">Faster</option>
|
<option value="Faster">Faster</option>
|
||||||
</select>
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<label for="number">Select a number:</label>
|
<label for="number">Select a number:</label>
|
||||||
<select name="number" id="number">
|
<select name="number" id="number">
|
||||||
|
@ -3,12 +3,45 @@
|
|||||||
module("selectmenu: options");
|
module("selectmenu: options");
|
||||||
|
|
||||||
test("appendTo another element", function () {
|
test("appendTo another element", function () {
|
||||||
expect(2);
|
expect( 8 );
|
||||||
|
|
||||||
var element = $("#speed").selectmenu();
|
var detached = $( "<div>" ),
|
||||||
|
element = $("#speed").selectmenu();
|
||||||
|
equal( element.selectmenu( "menuWidget" ).parent().parent()[0], document.body, "defaults to body" );
|
||||||
|
element.selectmenu( "destroy" );
|
||||||
|
|
||||||
ok(element.selectmenu("option", "appendTo", "#qunit-fixture"), "appendTo accepts selector");
|
element.selectmenu({
|
||||||
ok($("#qunit-fixture").find(".ui-selectmenu-menu").length, "selectmenu appendedTo other element");
|
appendTo: ".sm-wrap"
|
||||||
|
});
|
||||||
|
equal( element.selectmenu( "menuWidget" ).parent().parent()[0], $( "#sm-wrap1" )[0], "first found element" );
|
||||||
|
equal( $( "#sm-wrap2 .ui-selectmenu" ).length, 0, "only appends to one element" );
|
||||||
|
element.selectmenu( "destroy" );
|
||||||
|
|
||||||
|
$( "#sm-wrap2" ).addClass( "ui-front" );
|
||||||
|
element.selectmenu();
|
||||||
|
equal( element.selectmenu( "menuWidget" ).parent().parent()[0], $( "#sm-wrap2" )[0], "null, inside .ui-front" );
|
||||||
|
element.selectmenu( "destroy" );
|
||||||
|
$( "#sm-wrap2" ).removeClass( "ui-front" );
|
||||||
|
|
||||||
|
element.selectmenu().selectmenu( "option", "appendTo", "#sm-wrap1" );
|
||||||
|
equal( element.selectmenu( "menuWidget" ).parent().parent()[0], $( "#sm-wrap1" )[0], "modified after init" );
|
||||||
|
element.selectmenu( "destroy" );
|
||||||
|
|
||||||
|
element.selectmenu({
|
||||||
|
appendTo: detached
|
||||||
|
});
|
||||||
|
equal( element.selectmenu( "menuWidget" ).parent().parent()[0], detached[0], "detached jQuery object" );
|
||||||
|
element.selectmenu( "destroy" );
|
||||||
|
|
||||||
|
element.selectmenu({
|
||||||
|
appendTo: detached[0]
|
||||||
|
});
|
||||||
|
equal( element.selectmenu( "menuWidget" ).parent().parent()[0], detached[0], "detached DOM element" );
|
||||||
|
element.selectmenu( "destroy" );
|
||||||
|
|
||||||
|
element.selectmenu().selectmenu( "option", "appendTo", detached );
|
||||||
|
equal( element.selectmenu( "menuWidget" ).parent().parent()[0], detached[0], "detached DOM element via option()" );
|
||||||
|
element.selectmenu( "destroy" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user