Test.Mock Class
yui3/src/test/js/Mock.js:1
Creates a new mock object.
Methods
expect
-
mock
-
expectation
Assigns an expectation to a mock object. This is used to create methods and properties on the mock object that are monitored for calls and changes, respectively.
Parameters:
-
mock
ObjectThe object to add the expectation to.
-
expectation
ObjectAn object defining the expectation. For properties, the keys "property" and "value" are required. For a method the "method" key defines the method's name, the optional "args" key provides an array of argument types. The "returns" key provides an optional return value. An optional "run" key provides a function to be used as the method body. The return value of a mocked method is determined first by the "returns" key, then the "run" function's return value. If neither "returns" nor "run" is provided undefined is returned. An optional 'error' key defines an error type to be thrown in all cases. The "callCount" key provides an optional number of times the method is expected to be called (the default is 1).
verify
-
mock
Verifies that all expectations of a mock object have been met and throws an assertion error if not.
Parameters:
-
mock
ObjectThe object to verify..