aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2015-04-14 13:30:58 -0400
committerRichard Gibson <richard.gibson@gmail.com>2015-04-22 15:25:35 -0400
commit35295f1c20d6f4ce724840ecad00d347ca5a1295 (patch)
tree71d0001a0a8fe657f663036dedfcf36a254d068f /test/unit
parent0de798d6c2277a286c90e08de669a23e6e12a4a2 (diff)
downloadjquery-35295f1c20d6f4ce724840ecad00d347ca5a1295.tar.gz
jquery-35295f1c20d6f4ce724840ecad00d347ca5a1295.zip
Deferred: Always handle progress callbacks before done/fail
Fixes gh-2013 Fixes gh-2010 Closes gh-2210 (cherry picked from commit 002240a6eb1cee2fcd886d5cf44893eb67f246f1)
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/deferred.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/unit/deferred.js b/test/unit/deferred.js
index c2dcf33d0..97f9111dd 100644
--- a/test/unit/deferred.js
+++ b/test/unit/deferred.js
@@ -565,6 +565,54 @@ test( "jQuery.Deferred.then - progress and thenables", function( assert ) {
trigger.notify();
});
+test( "jQuery.Deferred - notify and resolve", function( assert ) {
+
+ expect( 7 );
+
+ var notifiedResolved = jQuery.Deferred().notify( "foo" )/*xxx .resolve( "bar" )*/,
+ done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );
+
+ notifiedResolved.progress( function( v ) {
+ assert.strictEqual( v, "foo", "progress value" );
+ } );
+
+ notifiedResolved.pipe().progress( function( v ) {
+ assert.strictEqual( v, "foo", "piped progress value" );
+ } );
+
+ notifiedResolved.pipe( null, null, function() {
+ return "baz";
+ } ).progress( function( v ) {
+ assert.strictEqual( v, "baz", "replaced piped progress value" );
+ } );
+
+ notifiedResolved.pipe( null, null, function() {
+ return jQuery.Deferred().notify( "baz" ).resolve( "quux" );
+ } ).progress( function( v ) {
+ assert.strictEqual( v, "baz", "deferred replaced piped progress value" );
+ } );
+
+ notifiedResolved.then().progress( function( v ) {
+ assert.strictEqual( v, "foo", "then'd progress value" );
+ done.pop().call();
+ } );
+
+ notifiedResolved.then( null, null, function() {
+ return "baz";
+ } ).progress( function( v ) {
+ assert.strictEqual( v, "baz", "replaced then'd progress value" );
+ done.pop().call();
+ } );
+
+ notifiedResolved.then( null, null, function() {
+ return jQuery.Deferred().notify( "baz" ).resolve( "quux" );
+ } ).progress( function( v ) {
+ // Progress from the surrogate deferred is ignored
+ assert.strictEqual( v, "quux", "deferred replaced then'd progress value" );
+ done.pop().call();
+ } );
+});
+
test( "jQuery.when", function() {
expect( 37 );