SpiedFn extends Function

Represents a function that is spied.

Constructor

SpiedFn(Object scope, String name)

[scope]

Object

The scope that the function is in. If undefined, then the original function will never be called and #restore will do nothing.

[name]

String

The name of the function that is spied, if scope is given.

Object [scope]

The scope that the function is in. If undefined, then the original function will never be called and #restore will do nothing.

String [name]

The name of the function that is spied, if scope is given.

Properties

Array records

Array of record objects, each containing an invocation for the function. Each invocation is a mapping of timestamp -> array of arguments used to invoke it.

Methods

overrideReturn(Object returnValue) => SpiedFn

Returns the given return value instead of the original function's.

[returnValue]

Object

Return value to return instead of calling the original function.

Object [returnValue]

Return value to return instead of calling the original function.

return SpiedFn

The current object.

record(Array args)

Records a function call.

args

Array

Array containing arguments to the function call.

Array args

Array containing arguments to the function call.

restore()

Restores the spied function.