static Spies
Root object for the library.
Methods
anyCallCountOf(Function target) => Number
callCountOf(SpiedFn target) => Function
Returns a function that returns the call count of the given target when called with the given
arguments. For example: Spies.callCountOf(fn)(1, 2) returns the number of calls that function
fn was called with arguments (1, 2).
If the passed in function is not a spy, this will return 0.
|
|
The function whose call count should be returned. |
||
SpiedFntargetThe function whose call count should be returned.
return FunctionFunction that returns the call counts of the given function.
invocationsOf(SpiedFn target) => Function
Returns a function that returns the invocations of the given target when called with the given
arguments. For example: Spies.invocationsOf(fn)(1, 2) returns an array of invocations
matching when fn is called with arguments (1, 2).
An invocation object consists of two values:
timestamp: This is the timestamp of the call. This only determines ordering, not actual time.args: This is an array of arguments that the function received at that time.
|
|
The function whose invocations should be returned. |
||
SpiedFntargetThe function whose invocations should be returned.
return FunctionFunction thar returns the invocations of the given function.
reset(Function | Object target)
Restores the given function or recursively all functions in the given object to its original implementation and removes all records related to it. Or, restores all known functions, if no arguments is given.
|
|
The function or object to be reset. |
||
spiedFunction() => SpiedFn
Creates a spied function.
return SpiedFnSpied function.
spy(Object scope, String name) => Object | Function
Spies the given function, or recursively all functions in the given object.
|
|
The Object to be spied on, or the object containing the function to be spied on. |
||
|
|
The name of the function to be spied on. If not specified, this will spy all functions in the scope recursively. |
||
stub(Function | Object ctor) => Object