# Yahoo! UI Library

### test 3.3.0

Yahoo! UI Library > test > Mock
Search:
Filters Show Private Show Protected Show Deprecated

## Class Mock

Creates a new mock object.

### Constructor

Mock `( template )`

Parameters:
  `template <Object>` (Optional) An object whose methods should be stubbed out on the mock object. This object is used as the prototype of the mock object so instanceof works correctly.

### Properties

#### Any - `static Function`

Mock argument validator that accepts any value as valid.

#### Boolean - `static Function`

Mock argument validator that accepts only Boolean values as valid.

#### Function - `static Function`

Mock argument validator that accepts onlyfunctions as valid.

#### Number - `static Function`

Mock argument validator that accepts only numeric values as valid.

#### Object - `static Function`

Mock argument validator that accepts only non-null objects values as valid.

#### String - `static Function`

Mock argument validator that accepts only String values as valid.

### Methods

#### expect

`static void 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 <Object>` The object to add the expectation to.
  `expectation <Object>` An object defining the expectation. For a method, the keys "method" and "args" are required with an optional "returns" key available. For properties, the keys "property" and "value" are required.

#### verify

`static void verify ( mock )`
Verifies that all expectations of a mock object have been met and throws an assertion error if not.

Parameters:
  `mock <Object>` The object to verify..

Copyright © 2011 Yahoo! Inc. All rights reserved.