mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Dialog: Extend visual test to verify DOM position restore on destroy; overhaul unit test for destroy method.
This commit is contained in:
parent
999617343f
commit
b694409e76
@ -45,6 +45,17 @@
|
||||
<div id="qunit-fixture">
|
||||
<div id="dialog1"></div>
|
||||
<div id="dialog2"></div>
|
||||
<div id="form-dialog" title="Profile Information">
|
||||
<fieldset>
|
||||
<legend>Please share some personal information</legend>
|
||||
<label for="favorite-animal">Your favorite animal</label><input id="favorite-animal">
|
||||
<label for="favorite-color">Your favorite color</label><input id="favorite-color">
|
||||
</fieldset>
|
||||
<div role="group" aria-describedby="section2">
|
||||
<p id="section2">Some more (optional) information</p>
|
||||
<label for="favorite-food">Favorite food</label><input id="favorite-food">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -34,20 +34,17 @@ test("init", function() {
|
||||
});
|
||||
|
||||
test("destroy", function() {
|
||||
expect( 4 );
|
||||
|
||||
$("<div></div>").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');
|
||||
|
||||
$('<div></div>').dialog().dialog("destroy").remove();
|
||||
ok(true, '.dialog("destroy") called on disconnected DOMElement');
|
||||
|
||||
var expected = $('<div></div>').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() {
|
||||
|
@ -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();
|
||||
});
|
||||
</script>
|
||||
@ -91,13 +96,13 @@
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
|
||||
<a href="#">Outside link</a>
|
||||
|
||||
<button id="open-dialog">Reopen dialog</button>
|
||||
|
||||
<div id="dialog" title="Basic dialog">
|
||||
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
|
||||
<p><button id="open-datepicker">Open another window with a datepicker.</button></p>
|
||||
<p><button id="destroy-dialog">Self destruct</button></p>
|
||||
</div>
|
||||
|
||||
<div id="dialog-datepicker" title="A dialog with a datepicker">
|
||||
@ -110,5 +115,7 @@
|
||||
<input id="autocomplete" title="Try typing something!">
|
||||
</div>
|
||||
|
||||
<a href="#">Outside link</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user