File tree Expand file tree Collapse file tree 2 files changed +5
-16
lines changed Expand file tree Collapse file tree 2 files changed +5
-16
lines changed Original file line number Diff line number Diff line change @@ -296,8 +296,7 @@ var spyApi = {
296
296
var args = slice . call ( arguments ) ;
297
297
298
298
if ( this . fakes ) {
299
- var matchings = this . matchingFakes ( args , true ) ;
300
- var matching = matchings && matchings . pop ( ) ;
299
+ var matching = this . matchingFakes ( args , true ) . pop ( ) ;
301
300
302
301
if ( matching ) {
303
302
return matching ;
@@ -335,11 +334,7 @@ var spyApi = {
335
334
} ,
336
335
337
336
matchingFakes : function ( args , strict ) {
338
- if ( ! this . fakes ) {
339
- return undefined ;
340
- }
341
-
342
- return this . fakes . filter ( function ( fake ) {
337
+ return ( this . fakes || [ ] ) . filter ( function ( fake ) {
343
338
return fake . matches ( args , strict ) ;
344
339
} ) ;
345
340
} ,
Original file line number Diff line number Diff line change @@ -90,15 +90,9 @@ var proto = {
90
90
var args = slice . call ( arguments ) ;
91
91
var matchings = functionStub . matchingFakes ( args ) ;
92
92
93
- var fnStub ;
94
- if ( matchings ) {
95
- fnStub = matchings . sort ( function ( a , b ) {
96
- return a . matchingArguments . length - b . matchingArguments . length ;
97
- } ) . pop ( ) ;
98
- }
99
- if ( ! fnStub ) {
100
- fnStub = functionStub ;
101
- }
93
+ var fnStub = matchings . sort ( function ( a , b ) {
94
+ return a . matchingArguments . length - b . matchingArguments . length ;
95
+ } ) . pop ( ) || functionStub ;
102
96
return getCurrentBehavior ( fnStub ) . invoke ( this , arguments ) ;
103
97
} ;
104
98
You can’t perform that action at this time.
0 commit comments