aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornanto <nanto@moon.email.ne.jp>2013-01-08 16:27:13 +0100
committerDave Methvin <dave.methvin@gmail.com>2013-01-08 17:59:08 +0000
commit0c5d2fbabb39ef53a798535bc58690d34ea21351 (patch)
treefb69a7bec7e213f222c6bbed6cb99d3225b08414 /test
parent4694118ef79e0800d408b2bc442d0aa2aec1f3eb (diff)
downloadjquery-0c5d2fbabb39ef53a798535bc58690d34ea21351.tar.gz
jquery-0c5d2fbabb39ef53a798535bc58690d34ea21351.zip
Propagate context of returned deferred object in Deferred.then(). Fixes #13160.
Diffstat (limited to 'test')
-rw-r--r--test/unit/deferred.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/unit/deferred.js b/test/unit/deferred.js
index 86b0b3411..f9bc13a9c 100644
--- a/test/unit/deferred.js
+++ b/test/unit/deferred.js
@@ -273,7 +273,7 @@ test( "jQuery.Deferred.then - deferred (progress)", function() {
test( "jQuery.Deferred.then - context", function() {
- expect( 4 );
+ expect( 7 );
var context = {};
@@ -284,6 +284,12 @@ test( "jQuery.Deferred.then - context", function() {
strictEqual( value, 6, "proper value received" );
});
+ jQuery.Deferred().resolve().then(function() {
+ return jQuery.Deferred().resolveWith(context);
+ }).done(function() {
+ strictEqual( this, context, "custom context of returned deferred correctly propagated" );
+ });
+
var defer = jQuery.Deferred(),
piped = defer.then(function( value ) {
return value * 3;
@@ -295,6 +301,16 @@ test( "jQuery.Deferred.then - context", function() {
strictEqual( this, piped, "default context gets updated to latest promise in the chain" );
strictEqual( value, 6, "proper value received" );
});
+
+ var defer2 = jQuery.Deferred(),
+ piped2 = defer2.then();
+
+ defer2.resolve( 2 );
+
+ piped2.done(function( value ) {
+ strictEqual( this, piped2, "default context gets updated to latest promise in the chain (without passing function)" );
+ strictEqual( value, 2, "proper value received (without passing function)" );
+ });
});
test( "jQuery.when", function() {