diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2015-04-14 13:30:58 -0400 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2015-04-22 15:24:37 -0400 |
commit | 002240a6eb1cee2fcd886d5cf44893eb67f246f1 (patch) | |
tree | 0d874addac35f41ed2c72502cceceb03bc31247b /test/unit/deferred.js | |
parent | 55ac56aeda786a4d1b677aefd3f5bb134ecb02ad (diff) | |
download | jquery-002240a6eb1cee2fcd886d5cf44893eb67f246f1.tar.gz jquery-002240a6eb1cee2fcd886d5cf44893eb67f246f1.zip |
Deferred: Always handle progress callbacks before done/fail
Fixes gh-2013
Fixes gh-2010
Closes gh-2210
Diffstat (limited to 'test/unit/deferred.js')
-rw-r--r-- | test/unit/deferred.js | 48 |
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 ); |