-
all(index) → {Array}
-
Returns the context (the this) and arguments passed all calls.
Parameters:
| Name |
Type |
Description |
index |
Number
|
|
Returns:
-
Type
-
Array
-
allArgs() → {Array}
-
Returns the arguments to all calls.
Returns:
-
Type
-
Array
-
any() → {Boolean}
-
Returns:
True if there were any calls to the spy
-
Type
-
Boolean
-
argsFor(index) → {Array}
-
Returns the arguments passed to a specific call.
Parameters:
| Name |
Type |
Description |
index |
Number
|
|
Returns:
-
Type
-
Array
-
count() → {Number}
-
Returns the number of times the spy was called.
Returns:
-
Type
-
Number
-
first() → {Object}
-
Returns the context (the this) and arguments for the first call.
Returns:
An object; the property object contains the this object, the property arg is an
array that contains the arguments
-
Type
-
Object
-
mostRecent() → {Object}
-
Returns the context (the this) and arguments for the most recent call.
Returns:
An object; the property object contains the this object, the property arg is an
array that contains the arguments
-
Type
-
Object
-
reset()
-
Resets all of a spy's the tracking variables so that it can be used again.
Example
spyOn(foo, 'bar');
foo.bar();
expect(foo.bar.calls.count()).toEqual(1);
foo.bar.and.reset();
expect(foo.bar.calls.count()).toEqual(0);