Caplin Trader 5.0.0

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

addSubFixtures(fixtureRegistry)

This optional interface method can be implemented by a Fixture for a complex system which can be conceptually decomposed into separate sub-systems, enabling the fixture to delegate the handling of some fixture properties to the sub-fixtures. This method is called by the GWTTestRunner.

Parameters:
Name Type Description
fixtureRegistry module:br-test/FixtureRegistry

The registry to which the fixtures should be registered.

Implements:

canHandleProperty(propertyName) → {Boolean}

This method is called by the GWTTestRunner to check whether a property used in a GWT test is supported by the fixture.

Parameters:
Name Type Description
propertyName String

the property name to check.

Implements:
Returns:

true if the fixture handles the property; false otherwise.

Type
Boolean

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

tearDown()

This method is called just after a GWT test. This optional interface method can be implemented if the fixture is required to correctly tear down the system-under-test after each test or to reset any state held in the fixture's implementation.

Implements: