Class goog.testing.Mock
code »- All implemented interfaces:
goog.testing.MockInterface
The base class for a mock object.
Constructor
Parameters |
---|
|
Instance Methods
code »$anyTimes ( ) ⇒ !goog.testing.Mock
Allows the expectation to be called any number of times.
!goog.testing.Mock
Returns |
---|
|
code »$argumentsAsString ( args ) ⇒ string
Render the provided argument array to a string to help
clients with debugging tests.
string
Parameters |
---|
|
Returns |
|
Allows the expectation to be called any number of times, as long as it's
called once.
Returns |
---|
|
Allows the expectation to be called 0 or 1 times.
Returns |
---|
|
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.
Parameters |
---|
|
Returns |
|
code »$does ( func ) ⇒ !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.
!goog.testing.Mock
Parameters |
---|
|
Returns |
|
code »$initializeFunctions_ ( objectToMock )Initializes the functions on the mock object.
Parameters |
---|
|
code »$maybeThrow ( expectation )If the expectation expects to throw, this method will throw.
Parameters |
---|
|
code »$mockMethod ( name ) ⇒ *
The function that replaces all methods on the mock object.
*
Parameters |
---|
|
Returns |
|
code »$never ( ) ⇒ !goog.testing.Mock
Disallows the expectation from being called.
!goog.testing.Mock
Returns |
---|
|
code »$once ( ) ⇒ !goog.testing.Mock
Allows the expectation to be called exactly once.
!goog.testing.Mock
Returns |
---|
|
code »$recordAndThrow ( ex )Throws an exception and records that an exception was thrown.
code »$recordCall ( name, args ) ⇒ *
Records an actual method call, intended to be overridden by a
subclass. The subclass must find the pending expectation and return the
correct value.
*
Records the currently pending expectation, intended to be overridden by a
subclass.
code »$registerArgumentListVerifier ( methodName, fn ) ⇒ !goog.testing.Mock
Registers a verfifier function to use when verifying method argument lists.
!goog.testing.Mock
code »$returns ( val ) ⇒ !goog.testing.Mock
Specifies a return value for the currently pending expectation.
!goog.testing.Mock
Parameters |
---|
|
Returns |
|
code »$throwCallException ( name, args, opt_expectation )Throw an exception based on an incorrect method call.
Parameters |
---|
|
code »$throwException ( comment, opt_message )Throws an exception and records that an exception was thrown.
code »$throws ( val ) ⇒ !goog.testing.Mock
Specifies a value for the currently pending expectation to throw.
!goog.testing.Mock
Parameters |
---|
|
Returns |
|
code »$times ( times ) ⇒ !goog.testing.Mock
Specifies the number of times the expectation should be called.
!goog.testing.Mock
Parameters |
---|
|
Returns |
|
code »$verifyCall ( expectation, name, args ) ⇒ boolean
Verifies that a method call matches an expectation.
boolean
Parameters |
---|
|
Returns |
|