Caplin Trader 4.7.1

Class: module:br/test/TimeFixture

module:br/test/TimeFixture

TimeFixture allows you to control when callbacks passed to window.setTimeout() and window.setInterval() are executed.
Currently setInterval() is not fully supported. It only fires once instead of repeating.

timeMode property
There are two modes supported by the TimeFixture:
  • 'NextStep' (default) - will automatically fire all timers at the end of each 'given, when or then' step (including 'and' steps)
  • 'Manual' - will stop the automatic-firing of timers on each 'given, when or then' step
passedBy property
When in 'Manual' mode, 'passedBy' is defined in milliseconds. Any function(s) registered to wait for a period less than (or equal to) the stated 'passedBy' value are then executed in ascending time order.

Example using 'NextStep' mode (default):
given("time.timeMode = 'NextStep'")
and(...)
// All timed events fired for the 'and' step above
and(...)
// All timed events fired for the 'and' step above
when(...)
// All timed events set up in the "when" step are fired
then(...)

Example using 'Manual' mode:
given("time.timeMode = 'Manual'")
and(...)
when(...)
and("time.passedBy => 2000")
// timed events from the 'given' and 'when' steps set to execute 2 seconds in the future are fired
then(...)

Constructor

new module:br/test/TimeFixture()

Implements:

Methods

doGiven(propertyName, value)

Parameters:
Name Type Description
propertyName String The property name (e.g. 'time.timeMode' or 'time.passedBy').
value Variant The value to set.
Implements:
See:
  • br.test.Fixture#doGiven

doThen(propertyName, value)

TimeFixture does not support doThen.
Parameters:
Name Type Description
propertyName String The property name.
value Variant The value to set.
Implements:
See:
  • br.test.Fixture#doThen

doWhen(propertyName, value)

Parameters:
Name Type Description
propertyName String The property name (e.g. 'time.timeMode' or 'time.passedBy').
value Variant The value to set.
Implements:
See:
  • br.test.Fixture#doWhen