File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,13 @@ describe('Spies', function () {
20
20
expect ( spy . bob ) . toEqual ( "test" ) ;
21
21
} ) ;
22
22
23
+ it ( "should allow you to omit the name argument and only pass the originalFn argument" , function ( ) {
24
+ var fn = function test ( ) { } ;
25
+ var spy = env . createSpy ( fn ) ;
26
+
27
+ expect ( spy . and . identity ) . toEqual ( "test" ) ;
28
+ } )
29
+
23
30
it ( "warns the user that we intend to overwrite an existing property" , function ( ) {
24
31
TestClass . prototype . someFunction . and = "turkey" ;
25
32
Original file line number Diff line number Diff line change @@ -474,6 +474,11 @@ getJasmineRequireObj().Env = function(j$) {
474
474
} ;
475
475
476
476
this . createSpy = function ( name , originalFn ) {
477
+ if ( arguments . length === 1 && j$ . isFunction_ ( name ) ) {
478
+ originalFn = name ;
479
+ name = originalFn . name ;
480
+ }
481
+
477
482
return spyFactory . createSpy ( name , originalFn ) ;
478
483
} ;
479
484
You can’t perform that action at this time.
0 commit comments