diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2023-05-10 13:39:56 +0200 |
---|---|---|
committer | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2023-05-10 17:34:14 +0200 |
commit | b715135d11706443df27c4a18f3f9a5dd190c236 (patch) | |
tree | be61bab6e700d6894a773a70d074128300d96774 /tests/unit/dialog/methods.js | |
parent | 23655f0dbdd0fff8498440ada710a32ad3ffc974 (diff) | |
download | jquery-ui-b715135d11706443df27c4a18f3f9a5dd190c236.tar.gz jquery-ui-b715135d11706443df27c4a18f3f9a5dd190c236.zip |
Tests: Workaround a dialog test issue by a proper cleanup
The `#favorite-animal` focus & blur handlers used to not be cleaned up after
the test automatically, leading to issues with some jQuery versions.
Diffstat (limited to 'tests/unit/dialog/methods.js')
-rw-r--r-- | tests/unit/dialog/methods.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/unit/dialog/methods.js b/tests/unit/dialog/methods.js index 5d01f223d..cfdc44bb2 100644 --- a/tests/unit/dialog/methods.js +++ b/tests/unit/dialog/methods.js @@ -214,7 +214,7 @@ QUnit.test( "Ensure form elements don't reset when opening a dialog", function( } ); QUnit.test( "#8958: dialog can be opened while opening", function( assert ) { - var ready = assert.async(); + var ready = assert.async( 3 ); assert.expect( 1 ); var element = $( "<div>" ).dialog( { @@ -227,7 +227,7 @@ QUnit.test( "#8958: dialog can be opened while opening", function( assert ) { } ); // Support: IE8 - // For some reason the #favorite-color input doesn't get focus if we don't + // For some reason the #favorite-animal input doesn't get focus if we don't // focus the body first, causing the test to hang. $( "body" ).trigger( "focus" ); @@ -238,6 +238,7 @@ QUnit.test( "#8958: dialog can be opened while opening", function( assert ) { // the dialog to gain focus, thus blurring the input. .on( "focus", function() { element.dialog( "open" ); + ready(); } ) // When the input blurs, the dialog is in the process of opening. We @@ -246,6 +247,12 @@ QUnit.test( "#8958: dialog can be opened while opening", function( assert ) { // being opened. .on( "blur", function() { element.dialog( "open" ); + + // Detach the handlers to avoid firing them outside of this + // test logic; this may affect other tests. + $( this ).off( "focus blur" ); + + ready(); } ) .trigger( "focus" ); } ); |