Options
All
  • Public
  • Public/Protected
  • All
Menu

A class to encapsulate accessing the system clock. By mocking out the 'now' method, unit tests can effectively control the flow of time in the tests, so long as the objects being tested always go through the ClockSource when accessing the system clock in any way.

Hierarchy

  • ClockSource

Index

Methods

Methods

now

  • now(): Date
  • Returns the current time from reading the system clock. Unit tests can override this method to control the progression of time in the test.

    Returns Date

waitUntil

  • waitUntil(until: Date): Promise<void>
  • Sleeps until the ClockSource reports that the current time is at least the time given.

    Parameters

    • until: Date

      when to wait until

    Returns Promise<void>