diff options
author | jaubourg <j@ubourg.net> | 2011-10-11 20:23:56 -0400 |
---|---|---|
committer | jaubourg <j@ubourg.net> | 2011-10-11 20:23:56 -0400 |
commit | d29182e8d00b08def0f37fe7e77d9836e39b83a8 (patch) | |
tree | dd38d2e32abc6d0a2d369000bfc2b6bc13e9d335 /test | |
parent | 511c9fe763bac171bb6ac3ac0a77c425da8b3112 (diff) | |
download | jquery-d29182e8d00b08def0f37fe7e77d9836e39b83a8.tar.gz jquery-d29182e8d00b08def0f37fe7e77d9836e39b83a8.zip |
Removes isPending and introduces state as a means to retrieve the Deferred/Promise state. Unit tests amended.
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/deferred.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/test/unit/deferred.js b/test/unit/deferred.js index f8232f9cc..9b99ae541 100644 --- a/test/unit/deferred.js +++ b/test/unit/deferred.js @@ -8,11 +8,12 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) { test("jQuery.Deferred" + withNew, function() { - expect( 20 ); + expect( 22 ); createDeferred().resolve().then( function() { ok( true , "Success on resolve" ); ok( this.isResolved(), "Deferred is resolved" ); + strictEqual( this.state(), "resolved", "Deferred is resolved (state)" ); }, function() { ok( false , "Error on resolve" ); }).always( function() { @@ -24,6 +25,7 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) { }, function() { ok( true , "Error on reject" ); ok( this.isRejected(), "Deferred is rejected" ); + strictEqual( this.state(), "rejected", "Deferred is rejected (state)" ); }).always( function() { ok( true , "Always callback on reject" ); }); @@ -37,7 +39,7 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) { jQuery.each( "resolve reject".split( " " ), function( _, change ) { createDeferred( function( defer ) { - ok( defer.isPending(), "pending after creation" ); + strictEqual( defer.state(), "pending", "pending after creation" ); var checked = 0; defer.progress(function( value ) { strictEqual( value, checked, "Progress: right value (" + value + ") received" ); @@ -45,9 +47,9 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) { for( checked = 0; checked < 3 ; checked++ ) { defer.notify( checked ); } - ok( defer.isPending(), "pending after notification" ); + strictEqual( defer.state(), "pending", "pending after notification" ); defer[ change ](); - ok( !defer.isPending(), "not pending after " + change ); + notStrictEqual( defer.state(), "pending", "not pending after " + change ); defer.notify(); }); }); |