labs.mock.MockObjectManager_ Extends goog.labs.mock.MockManager_
Sets up mock for the given object (or class), stubbing out all the defined methods. By default, all stubs return undefined, though stubs can be later defined using goog.labs.mock.when.

Inheritance

Constructor

goog.labs.mock.MockObjectManager_(objOrClass)

Parameters

objOrClass : !Object | !Function
The object or class to set up the mock for. A class is a constructor function.

Instance Methods

Public Protected Private
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 »
objectCallVerifier_ :
The call verifier is used to verify the calls. It maps property names to the method that does call verification.
Code »
objectStubBinder_ :
Proxies the calls to establish the first step of the stub bindings (object and method 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.MockObjectManager_.superClass_ :
No description.
Code »

Package labs.mock

Package Reference