Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deferred: Propagate progress correctly from unwrapped promises #3150

Merged
merged 1 commit into from Jun 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/deferred.js
Expand Up @@ -162,7 +162,7 @@ jQuery.extend( {
resolve( maxDepth, deferred, Identity, special ),
resolve( maxDepth, deferred, Thrower, special ),
resolve( maxDepth, deferred, Identity,
deferred.notify )
deferred.notifyWith )
);
}

Expand Down
30 changes: 30 additions & 0 deletions test/unit/deferred.js
Expand Up @@ -768,6 +768,36 @@ QUnit.test( "jQuery.Deferred - notify and resolve", function( assert ) {
} );
} );

QUnit.test( "jQuery.Deferred - resolved to a notifying deferred", function( assert ) {

assert.expect( 2 );

var deferred = jQuery.Deferred(),
done = assert.async( 2 );

deferred.resolve( jQuery.Deferred( function( notifyingDeferred ) {
notifyingDeferred.notify( "foo", "bar" );
notifyingDeferred.resolve( "baz", "quux" );
} ) );

// Apply an empty then to force thenable unwrapping.
// See https://github.com/jquery/jquery/issues/3000 for more info.
deferred.then().then( function() {
assert.deepEqual(
[].slice.call( arguments ),
[ "baz", "quux" ],
"The fulfilled handler receives proper params"
);
done();
}, null, function() {
assert.deepEqual(
[].slice.call( arguments ),
[ "foo", "bar" ],
"The progress handler receives proper params"
);
done();
} );
} );

QUnit.test( "jQuery.when(nonThenable) - like Promise.resolve", function( assert ) {
"use strict";
Expand Down