The goog.testing.StrictMock Class

goog.testing.StrictMock
> goog.testing.Mock

goog.testing.StrictMock(objectToMock, opt_mockStaticMethods, opt_createProxy)

This is a mock that verifies that methods are called in the order that they are specified during the recording phase. Since it verifies order, it follows 'fail fast' semantics. If it detects a deviation from the expectations, it will throw an exception and not wait for verify to be called.

objectToMock {Object}
The object to mock.
opt_mockStaticMethods {boolean=}
An optional argument denoting that a mock should be constructed from the static functions of a class.
opt_createProxy {boolean=}
An optional argument denoting that a proxy for the target mock should be created.

.$anyTimes()

Inherited from goog.testing.Mock .

Allows the expectation to be called any number of times.

returns {goog.testing.Mock}
This mock object.

.$argumentListVerifiers_ {Object}

Inherited from goog.testing.Mock .

Map of argument name to optional argument list verifier function.

.$argumentsAsString(args)

Inherited from goog.testing.Mock .

Render the provided argument array to a string to help clients with debugging tests.

args {Array.<*>?}
The arguments passed to the mock.
returns {string}
Human-readable string.

.$atLeastOnce()

Inherited from goog.testing.Mock .

Allows the expectation to be called any number of times, as long as it's called once.

returns {goog.testing.Mock}
This mock object.

.$atMostOnce()

Inherited from goog.testing.Mock .

Allows the expectation to be called 0 or 1 times.

returns {goog.testing.Mock}
This mock object.

.$do(expectation, args)

Inherited from goog.testing.Mock .

If this expectation defines a function to be called, it will be called and its result will be returned. Otherwise, if the expectation expects to throw, it will throw. Otherwise, this method will return defined value.

expectation {goog.testing.MockExpectation}
The expectation.
args {Array}
The arguments to the method.
returns {*}
The return value expected by the mock.

.$does(func)

Inherited from goog.testing.Mock .

Specifies a function to call for currently pending expectation. Note, that using this method overrides declarations made using $returns() and $throws() methods.

func {Function}
The function to call.
returns {goog.testing.Mock}
This mock object.

.$maybeThrow(expectation)

Inherited from goog.testing.Mock .

If the expectation expects to throw, this method will throw.

expectation {goog.testing.MockExpectation}
The expectation.

.$mockMethod(name)

Inherited from goog.testing.Mock .

The function that replaces all methods on the mock object.

name {string}
The name of the method being mocked.
returns {*}
In record mode, returns the mock object. In replay mode, returns whatever the creator of the mock set as the return value.

.$proxy {Object}

Inherited from goog.testing.Mock .

A proxy for the mock. This can be used for dependency injection in lieu of the mock if the test requires a strict instanceof check.

.$registerArgumentListVerifier(methodName, fn)

Inherited from goog.testing.Mock .

Registers a verfifier function to use when verifying method argument lists.

methodName {string}
The name of the method for which the verifierFn should be used.
fn {Function}
Argument list verifier function. Should take 2 argument arrays as arguments, and return true if they are considered equivalent.
returns {goog.testing.Mock}
This mock object.

.$replay()

Inherited from goog.testing.Mock .

Switches from recording to replay mode.

.$reset()

Resets the state of this mock object. This clears all pending expectations without verifying, and puts the mock in recording mode.

.$returns(val)

Inherited from goog.testing.Mock .

Specifies a return value for the currently pending expectation.

val {*}
The return value.
returns {goog.testing.Mock}
This mock object.

.$throwCallException(name, args, opt_expectation)

Inherited from goog.testing.Mock .

Throw an exception based on an incorrect method call.

name {string}
Name of method called.
args {Array.<*>?}
Arguments passed to the mock.
opt_expectation {goog.testing.MockExpectation=}
Expected next call, if any.

.$throws(val)

Inherited from goog.testing.Mock .

Specifies a value for the currently pending expectation to throw.

val {*}
The value to throw.
returns {goog.testing.Mock}
This mock object.

.$times(times)

Inherited from goog.testing.Mock .

Specifies the number of times the expectation should be called.

times {number}
The number of times this method will be called.
returns {goog.testing.Mock}
This mock object.

.$verify()

Verify that all of the expectations were met. Should be overridden by subclasses.

.$verifyCall(expectation, name, args)

Inherited from goog.testing.Mock .

Verifies that a method call matches an expectation.

expectation {goog.testing.MockExpectation}
The expectation to check.
name {string}
The name of the called method.
args {Array.<*>?}
The arguments passed to the mock.
returns {boolean}
Whether the call matches the expectation.