]> source.dussan.org Git - jquery.git/commitdiff
Tests: Pass a number of necessary done() calls to assert.async()
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Mon, 2 Mar 2020 21:15:06 +0000 (22:15 +0100)
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Mon, 2 Mar 2020 21:18:10 +0000 (22:18 +0100)
It is no longer needed to create `done` wrappers in tests that require
multiple async operations to complete.

Closes gh-4633

(cherry picked from commit 364476c3dc1231603ba61fc08068fa89fb095e1a)

test/unit/basic.js
test/unit/ready.js

index c42ee54508e5096a0dfde27ab288e0e837722719..9cb7d25beffa73c605b115f39771ea52776fc690 100644 (file)
@@ -4,14 +4,14 @@ if ( jQuery.ajax ) {
 QUnit.test( "ajax", function( assert ) {
        assert.expect( 4 );
 
-       var done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );
+       var done = assert.async( 3 );
 
        jQuery.ajax( {
                type: "GET",
                url: url( "mock.php?action=name&name=foo" ),
                success: function( msg ) {
                        assert.strictEqual( msg, "bar", "Check for GET" );
-                       done.pop()();
+                       done();
                }
        } );
 
@@ -21,14 +21,14 @@ QUnit.test( "ajax", function( assert ) {
                data: "name=peter",
                success: function( msg ) {
                        assert.strictEqual( msg, "pan", "Check for POST" );
-                       done.pop()();
+                       done();
                }
        } );
 
        jQuery( "#first" ).load( url( "name.html" ), function() {
                assert.ok( /^ERROR/.test( jQuery( "#first" ).text() ),
                        "Check if content was injected into the DOM" );
-               done.pop()();
+               done();
        } );
 } );
 }
index fd33c0a18fc887de5005a577319d5cec6be0c248..d1a728b47d2ac339ed62351b021ee1396e918187 100644 (file)
@@ -107,31 +107,31 @@ QUnit.module( "ready" );
 
        QUnit[ jQuery.when ? "test" : "skip" ]( "jQuery.when(jQuery.ready)", function( assert ) {
                assert.expect( 2 );
-               var done = jQuery.map( new Array( 2 ), function() { return assert.async(); } );
+               var done = assert.async( 2 );
 
                whenified.then( function() {
                        assert.ok( jQuery.isReady, "jQuery.when Deferred resolved" );
-                       done.pop()();
+                       done();
                } );
 
                jQuery.when( jQuery.ready ).then( function() {
                        assert.ok( jQuery.isReady, "jQuery.when Deferred resolved" );
-                       done.pop()();
+                       done();
                } );
        } );
 
        QUnit.test( "Promise.resolve(jQuery.ready)", function( assert ) {
                assert.expect( 2 );
-               var done = jQuery.map( new Array( 2 ), function() { return assert.async(); } );
+               var done = assert.async( 2 );
 
                promisified.then( function() {
                        assert.ok( jQuery.isReady, "Native promised resolved" );
-                       done.pop()();
+                       done();
                } );
 
                Promise.resolve( jQuery.ready ).then( function() {
                        assert.ok( jQuery.isReady, "Native promised resolved" );
-                       done.pop()();
+                       done();
                } );
        } );