aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2012-12-07 14:54:21 -0500
committerScott González <scott.gonzalez@gmail.com>2012-12-07 14:54:21 -0500
commit70b16ef445d8f9947fd414894d97673706ee8c6f (patch)
tree92eae7fe43e1488dd7a1e9e3840cd7cc5c247b45 /tests
parentda17a232ca554254eabd3583805b381f6b525ec5 (diff)
downloadjquery-ui-70b16ef445d8f9947fd414894d97673706ee8c6f.tar.gz
jquery-ui-70b16ef445d8f9947fd414894d97673706ee8c6f.zip
Dialog: Added appendTo option. Fixes #7948 - Dialog: Allow dialog to be attached to a element other than body.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/dialog/dialog.html2
-rw-r--r--tests/unit/dialog/dialog_common.js1
-rw-r--r--tests/unit/dialog/dialog_options.js41
3 files changed, 44 insertions, 0 deletions
diff --git a/tests/unit/dialog/dialog.html b/tests/unit/dialog/dialog.html
index cdc846478..8f2583ce1 100644
--- a/tests/unit/dialog/dialog.html
+++ b/tests/unit/dialog/dialog.html
@@ -61,6 +61,8 @@
<label for="favorite-food">Favorite food</label><input id="favorite-food">
</div>
</div>
+ <div class="wrap" id="wrap1"></div>
+ <div class="wrap" id="wrap2"></div>
</div>
</body>
</html>
diff --git a/tests/unit/dialog/dialog_common.js b/tests/unit/dialog/dialog_common.js
index 47fff1013..9657a9887 100644
--- a/tests/unit/dialog/dialog_common.js
+++ b/tests/unit/dialog/dialog_common.js
@@ -1,5 +1,6 @@
TestHelpers.commonWidgetTests( "dialog", {
defaults: {
+ appendTo: "body",
autoOpen: true,
buttons: {},
closeOnEscape: true,
diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js
index fd7d91827..19e69b29a 100644
--- a/tests/unit/dialog/dialog_options.js
+++ b/tests/unit/dialog/dialog_options.js
@@ -5,6 +5,47 @@
module("dialog: options");
+test( "appendTo", function() {
+ expect( 8 );
+ var detached = $( "<div>" ),
+ element = $( "#dialog1" ).dialog();
+ equal( element.dialog( "widget" ).parent()[0], document.body, "defaults to body" );
+ element.dialog( "destroy" );
+
+ element.dialog({
+ appendTo: ".wrap"
+ });
+ equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "first found element" );
+ equal( $( "#wrap2 .ui-dialog" ).length, 0, "only appends to one element" );
+ element.dialog( "destroy" );
+
+ element.dialog({
+ appendTo: null
+ });
+ equal( element.dialog( "widget" ).parent()[0], document.body, "null" );
+ element.dialog( "destroy" );
+
+ element.dialog({ autoOpen: false }).dialog( "option", "appendTo", "#wrap1" ).dialog( "open" );
+ equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "modified after init" );
+ element.dialog( "destroy" );
+
+ element.dialog({
+ appendTo: detached
+ });
+ equal( element.dialog( "widget" ).parent()[0], detached[0], "detached jQuery object" );
+ element.dialog( "destroy" );
+
+ element.dialog({
+ appendTo: detached[0]
+ });
+ equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element" );
+ element.dialog( "destroy" );
+
+ element.dialog({ autoOpen: false }).dialog( "option", "appendTo", detached );
+ equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element via option()" );
+ element.dialog( "destroy" );
+});
+
test("autoOpen", function() {
expect(2);