Jasmine's mock clock is used when testing time dependent code.
Note: Do not construct this directly, Jasmine will make one during booting. You can get the current clock with jasmine.clock
.
Install the mock clock over the built-in methods.
Instruct the installed Clock to also mock the date returned by new Date()
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
initialDate | Date | <optional> | now | The |
Tick the Clock forward, running any enqueued timeouts along the way
Name | Type | Description |
---|---|---|
millis | int | The number of milliseconds to tick. |
Uninstall the mock clock, returning the built-in methods to their places.
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.
Name | Type | Description |
---|---|---|
Function | closure | The function to be called. |
© 2008–2017 Pivotal Labs
Licensed under the MIT License.
https://jasmine.github.io/api/3.2/Clock.html