From b694409e76181dbfdfec9419d9c3f688ff183a53 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rn=20Zaefferer?= Date: Fri, 16 Nov 2012 19:33:55 +0100 Subject: [PATCH] Dialog: Extend visual test to verify DOM position restore on destroy; overhaul unit test for destroy method. --- tests/unit/dialog/dialog.html | 11 +++++++++++ tests/unit/dialog/dialog_methods.js | 25 +++++++++++------------- tests/visual/dialog/complex-dialogs.html | 11 +++++++++-- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/tests/unit/dialog/dialog.html b/tests/unit/dialog/dialog.html index 0022b42cf..0b5ca4856 100644 --- a/tests/unit/dialog/dialog.html +++ b/tests/unit/dialog/dialog.html @@ -45,6 +45,17 @@
+
+
+ Please share some personal information + + +
+
+

Some more (optional) information

+ +
+
diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index 7048a76a9..a4959bf85 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -34,20 +34,17 @@ test("init", function() { }); test("destroy", function() { - expect( 4 ); - - $("
").appendTo('body').dialog().dialog("destroy").remove(); - ok(true, '.dialog("destroy") called on element'); - - $([]).dialog().dialog("destroy").remove(); - ok(true, '.dialog("destroy") called on empty collection'); - - $('
').dialog().dialog("destroy").remove(); - ok(true, '.dialog("destroy") called on disconnected DOMElement'); - - var expected = $('
').dialog(), - actual = expected.dialog('destroy'); - equal(actual, expected, 'destroy is chainable'); + expect( 6 ); + domEqual( "#dialog1", function() { + var dialog = $( "#dialog1" ).dialog().dialog( "destroy" ); + equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] ); + equal( dialog.index(), 0 ); + }); + domEqual( "#form-dialog", function() { + var dialog = $( "#form-dialog" ).dialog().dialog( "destroy" ); + equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] ); + equal( dialog.index(), 2 ); + }); }); test("enable", function() { diff --git a/tests/visual/dialog/complex-dialogs.html b/tests/visual/dialog/complex-dialogs.html index 46d2539c5..03bb160fb 100644 --- a/tests/visual/dialog/complex-dialogs.html +++ b/tests/visual/dialog/complex-dialogs.html @@ -24,7 +24,7 @@ $(function() { var dialog = $( "#dialog" ).dialog({ modal: true, - height: 300, + height: 350, width: 500, buttons: [ { @@ -82,6 +82,11 @@ ] }); + $( "#destroy-dialog" ).click(function() { + dialog.dialog( "destroy" ).show(); + $( this ).remove(); + }); + $( document ).tooltip(); }); @@ -91,13 +96,13 @@

WHAT: A modal dialog opening another modal dialog (including a datepicker), opening a non-modal dialog (including an autocomplete with tooltip applied). A regular link on the page, outside of the dialogs.

EXPECTED: As long as a modal dialog is open, focus stays within the dialogs. Both mouse and keyboard interactions are captured and restricted to the dialog. When the nested modal dialog is open, the first modal dialog can't be interacted with, until the nested dialog is closed. When the third dialog is open (not modal), switching between the two dialogs is possible, both can be interacted with.

-Outside link

This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.

+

@@ -110,5 +115,7 @@
+Outside link + -- 2.39.5