diff options
author | jaubourg <j@ubourg.net> | 2012-09-13 15:44:12 +0200 |
---|---|---|
committer | jaubourg <j@ubourg.net> | 2012-09-13 15:44:12 +0200 |
commit | 74cdd784975ba6e628d1934a859faeb017824a5f (patch) | |
tree | 8ff8503473fbafff2b4d2e563b936e2d9271b570 /test | |
parent | 9c5089a60d479a959b290a5b4ab8ef38c985e963 (diff) | |
download | jquery-74cdd784975ba6e628d1934a859faeb017824a5f.tar.gz jquery-74cdd784975ba6e628d1934a859faeb017824a5f.zip |
deferred.promise(obj) should work with non-objects. Fixes #12521. Much needed unit tests added!
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/deferred.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/test/unit/deferred.js b/test/unit/deferred.js index 8f512dac7..a786a05a9 100644 --- a/test/unit/deferred.js +++ b/test/unit/deferred.js @@ -8,7 +8,7 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) { test("jQuery.Deferred" + withNew, function() { - expect( 21 ); + expect( 23 ); var defer = createDeferred(); @@ -39,6 +39,22 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) { strictEqual( value , "done" , "Passed function executed" ); }); + createDeferred(function( defer ) { + var promise = defer.promise(), + func = function() {}, + funcPromise = defer.promise( func ); + strictEqual( defer.promise(), promise, "promise is always the same" ); + strictEqual( funcPromise, func, "non objects get extended" ); + jQuery.each( promise, function( key, value ) { + if ( !jQuery.isFunction( promise[ key ] ) ) { + ok( false, key + " is a function (" + jQuery.type( promise[ key ] ) + ")" ); + } + if ( promise[ key ] !== func[ key ] ) { + strictEqual( func[ key ], promise[ key ], key + " is the same" ); + } + }); + }); + jQuery.expandedEach = jQuery.each; jQuery.expandedEach( "resolve reject".split( " " ), function( _, change ) { createDeferred( function( defer ) { @@ -59,6 +75,7 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) { }); } ); + test( "jQuery.Deferred - chainability", function() { var defer = jQuery.Deferred(); |