aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2012-12-15 02:24:10 +0100
committerFelix Nagel <info@felixnagel.com>2012-12-15 02:24:10 +0100
commitae68ab8118d68ff7cd5114058d0243b6b0970ca8 (patch)
tree334f9584e3126a715a82c2403c291dca1c51b025 /tests
parent930e9d59937a264c652037c3a85bfa1145f416c3 (diff)
downloadjquery-ui-ae68ab8118d68ff7cd5114058d0243b6b0970ca8.tar.gz
jquery-ui-ae68ab8118d68ff7cd5114058d0243b6b0970ca8.zip
Selectmenu tests: improve appendTo option tests
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/selectmenu/selectmenu.html19
-rw-r--r--tests/unit/selectmenu/selectmenu_options.js41
2 files changed, 48 insertions, 12 deletions
diff --git a/tests/unit/selectmenu/selectmenu.html b/tests/unit/selectmenu/selectmenu.html
index d05b4f2be..a89b2d37d 100644
--- a/tests/unit/selectmenu/selectmenu.html
+++ b/tests/unit/selectmenu/selectmenu.html
@@ -37,15 +37,18 @@
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
+ <div id="sm-wrap1" class="sm-wrap"></div>
- <label for="speed">Select a speed:</label>
- <select name="speed" id="speed">
- <option value="Slower">Slower</option>
- <option value="Slow">Slow</option>
- <option value="Medium" selected="selected">Medium</option>
- <option value="Fast">Fast</option>
- <option value="Faster">Faster</option>
- </select>
+ <div id="sm-wrap2" class="sm-wrap">
+ <label for="speed">Select a speed:</label>
+ <select name="speed" id="speed">
+ <option value="Slower">Slower</option>
+ <option value="Slow">Slow</option>
+ <option value="Medium" selected="selected">Medium</option>
+ <option value="Fast">Fast</option>
+ <option value="Faster">Faster</option>
+ </select>
+ </div>
<label for="number">Select a number:</label>
<select name="number" id="number">
diff --git a/tests/unit/selectmenu/selectmenu_options.js b/tests/unit/selectmenu/selectmenu_options.js
index 440df04be..21e276b5d 100644
--- a/tests/unit/selectmenu/selectmenu_options.js
+++ b/tests/unit/selectmenu/selectmenu_options.js
@@ -3,12 +3,45 @@
module("selectmenu: options");
test("appendTo another element", function () {
- expect(2);
+ expect( 8 );
+
+ var detached = $( "<div>" ),
+ element = $("#speed").selectmenu();
+ equal( element.selectmenu( "menuWidget" ).parent().parent()[0], document.body, "defaults to body" );
+ element.selectmenu( "destroy" );
+
+ element.selectmenu({
+ 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" );
- var element = $("#speed").selectmenu();
+ element.selectmenu({
+ appendTo: detached[0]
+ });
+ equal( element.selectmenu( "menuWidget" ).parent().parent()[0], detached[0], "detached DOM element" );
+ element.selectmenu( "destroy" );
- ok(element.selectmenu("option", "appendTo", "#qunit-fixture"), "appendTo accepts selector");
- ok($("#qunit-fixture").find(".ui-selectmenu-menu").length, "selectmenu appendedTo other element");
+ element.selectmenu().selectmenu( "option", "appendTo", detached );
+ equal( element.selectmenu( "menuWidget" ).parent().parent()[0], detached[0], "detached DOM element via option()" );
+ element.selectmenu( "destroy" );
});