# `Klotho.Mock`

This is the backend is used in `:test` environment.

The module gives control of the mocked time and provides inspection
of triggered timers.

# `freeze`

```elixir
@spec freeze() :: :ok
```

Freeze time. In `frozen` mode, all calls to `monotonic_time` and `system_time`
will return the same value. Timers will be not triggered unless warp is called.
The function is idempotent.

# `reset`

```elixir
@spec reset() :: :ok
```

Reset the state of the time server. This
* resets the time to the actual current time;
* cleans timer history;
* resets the mode to `running`;
* cancels all timers.

# `timer_event_history`

```elixir
@spec timer_event_history() :: [Klotho.Mock.TimerMsg.t()]
```

Return history of all messages (`%Klotho.Mock.TimerMsg{}`) sent by triggered timers.
Most recent messages are first.

# `unfreeze`

```elixir
@spec unfreeze() :: :ok
```

Unreeze time. In `running` mode, all calls to `monotonic_time` and `system_time` will
start produce values increasing with "normal" monotonic time pace.
Timers will be triggered according to their schedule.

# `warp_by`

```elixir
@spec warp_by(non_neg_integer()) :: :ok
```

Warp time forward by `timer_interval` milliseconds.
Regardless of the current mode (frozen or running), all the timers
that are due to trigger within the next `timer_interval` milliseconds
will be triggered after warp.

# `warp_by`

```elixir
@spec warp_by(non_neg_integer(), :erlang.time_unit()) :: :ok
```

Warp time forward by `timer_interval` in `unit`.
Regardless of the current mode (frozen or running), all the timers
that are due to trigger within the next `timer_interval` milliseconds
will be triggered after warp.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
