- Since:
- 1.3.0
Methods
install() → {Clock}
Install the mock clock over the built-in methods.
- Since:
- 2.0.0
Returns:
- Type
- Clock
mockDate(initialDateopt)
Instruct the installed Clock to also mock the date returned by new Date()
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
initialDate |
Date |
<optional> |
now | The |
- Since:
- 2.1.0
tick(millis)
Tick the Clock forward, running any enqueued timeouts along the way
Parameters:
Name | Type | Description |
---|---|---|
millis |
int | The number of milliseconds to tick. |
- Since:
- 1.3.0
uninstall()
Uninstall the mock clock, returning the built-in methods to their places.
- Since:
- 2.0.0
withMock(closure)
Execute a function with a mocked Clock
The clock will be install
ed before the function is called and uninstall
ed in a finally
after the function completes.
Parameters:
Name | Type | Description |
---|---|---|
closure |
function | The function to be called. |
- Since:
- 2.3.0