@@ -8,7 +8,7 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
8
8
9
9
test ( "jQuery.Deferred" + withNew , function ( ) {
10
10
11
- expect ( 21 ) ;
11
+ expect ( 23 ) ;
12
12
13
13
var defer = createDeferred ( ) ;
14
14
@@ -39,6 +39,22 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
39
39
strictEqual ( value , "done" , "Passed function executed" ) ;
40
40
} ) ;
41
41
42
+ createDeferred ( function ( defer ) {
43
+ var promise = defer . promise ( ) ,
44
+ func = function ( ) { } ,
45
+ funcPromise = defer . promise ( func ) ;
46
+ strictEqual ( defer . promise ( ) , promise , "promise is always the same" ) ;
47
+ strictEqual ( funcPromise , func , "non objects get extended" ) ;
48
+ jQuery . each ( promise , function ( key , value ) {
49
+ if ( ! jQuery . isFunction ( promise [ key ] ) ) {
50
+ ok ( false , key + " is a function (" + jQuery . type ( promise [ key ] ) + ")" ) ;
51
+ }
52
+ if ( promise [ key ] !== func [ key ] ) {
53
+ strictEqual ( func [ key ] , promise [ key ] , key + " is the same" ) ;
54
+ }
55
+ } ) ;
56
+ } ) ;
57
+
42
58
jQuery . expandedEach = jQuery . each ;
43
59
jQuery . expandedEach ( "resolve reject" . split ( " " ) , function ( _ , change ) {
44
60
createDeferred ( function ( defer ) {
@@ -59,6 +75,7 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
59
75
} ) ;
60
76
} ) ;
61
77
78
+
62
79
test ( "jQuery.Deferred - chainability" , function ( ) {
63
80
64
81
var defer = jQuery . Deferred ( ) ;
0 commit comments