labs.mock.MockFunctionManager_ Extends goog.labs.mock.MockManager_
Sets up mock for the given function, stubbing out. By default, all stubs return undefined, though stubs can be later defined using goog.labs.mock.when.

Inheritance

Constructor

goog.labs.mock.MockFunctionManager_(func)

Parameters

func : !Function
The function to set up the mock for.

Instance Methods

Public Protected Private
useMockedFunctionName_(nextFunc) !Function
Given a method, returns a new function that calls the first one setting the first argument to the mocked function name. This is used to dynamically override the stub binders and call verifiers.
Arguments:
nextFunc : Function
The function to override.
Returns: !Function  The overloaded function.
code »
addBinding(methodNameargsfunc)
Adds a binding for the method name and arguments to be stubbed.
Arguments:
methodName : ?string
The name of the stubbed method.
args : !Array
The arguments passed to the method.
func : !Function
The stub function.
code »
executeStub(methodNamevar_args) *
Looks up the list of stubs defined on the mock object and executes the function associated with that stub.
Arguments:
methodName : string
The name of the method to execute.
var_args : ...
The arguments passed to the method.
Returns: *  Value returned by the stub function.
code »
findBinding(methodNameargs) Function
Returns a stub, if defined, for the method name and arguments passed in.
Arguments:
methodName : string
The name of the stubbed method.
args : !Array
The arguments passed to the method.
Returns: Function  The stub function or undefined.
code »
getExecutor(methodNameargs) Function
Returns a stub, if defined, for the method name and arguments passed in as parameters.
Arguments:
methodName : string
The name of the stubbed method.
args : !Array
The arguments passed to the method.
Returns: Function  The stub function or undefined.
code »
getMockedItem() !Object | !Function
Returns the mock object. This should have a stubbed method for each method on the object being mocked.
Returns: !Object | !Function  The mock object.
code »
handleMockCall_(methodNamevar_args) !goog.labs.mock.StubBinder_
Handles the first step in creating a stub, returning a stub-binder that is later used to bind a stub for a method.
Arguments:
methodName : string
The name of the method being bound.
var_args : ...
The arguments to the method.
Returns: !goog.labs.mock.StubBinder_  The stub binder.
code »
recordCall_(methodNameargs)
Records a call to 'methodName' with arguments 'args'.
Arguments:
methodName : string
The name of the called method.
args : !Array
The array of arguments.
code »
verifyInvocation(methodNamevar_args)
Verify invocation of a method with specific arguments.
Arguments:
methodName : string
The name of the method.
var_args : ...
The arguments passed.
code »

Instance Properties

constructor :
No description.
Code »
func_ :
No description.
Code »
functionStubBinder_ :
The stub binder used to create bindings. Sets the first argument of handleMockCall_ to the function name.
Code »
$stubBinder :
Holds a reference to the binder used to define stubs.
Code »
callRecords_ :
Record method calls with no stub definitions.
Code »
methodBindings :
Holds the stub bindings established so far.
Code »
mockedItem :
Proxies the methods for the mocked object or class to execute the stubs.
Code »
mockee :
A reference to the object or function being mocked.
Code »

Static Properties

goog.labs.mock.MockFunctionManager_.superClass_ :
No description.
Code »

Package labs.mock

Package Reference