Caplin Trader 4.7.1

Class: module:br/component/testing/ComponentFixture

module:br/component/testing/ComponentFixture

Constructs a ComponentFixture. The ComponentFixture serves to create components using the ComponentFactory when these are required in the system under test.

In addition to creating and opening the component, the ComponentFixture defines several sub-fixtures to be added to the test runner, enabling the testing and manipulation of the view and presentation model of the component.

Constructor

new module:br/component/testing/ComponentFixture(sXml, oModelFixture, oViewFixture)

Parameters:
Name Type Description
sXml String the component XML required to create the component. Required.
oModelFixture module:br/component/testing/ComponentModelFixture the presentation model fixture. Required.
oViewFixture module:br/test/ViewFixture the view fixture. Optional.
Implements:

Methods

addSubFixtures()

The ComponentFixture adds the following sub-fixtures:
  • model: the presentation model fixture, for manipulating and verifying properties in the presentation model
  • view: the view fixture, the view fixture, for manipulating and verifying the state of elements on the component's view
  • componentFrame: the component frame fixture, for verifying the state of the module:br/component/Frame housing the component
Implements:
See:
  • br.test.Fixture#addSubFixtures

addViewFixtureHandlers(viewHandlersMap)

Allows custom view handlers to be added. The ViewFixture's addViewHandlers method throws an exception if an attempt is made to override an existing handler.
Parameters:
Name Type Description
viewHandlersMap Map A map of handler name to handler class constructor reference

canHandleExactMatch()

Implements:
  • module:br/test/Fixture#canHandleExactMatch
See:
  • br.test.Fixture#canHandleExactMatch

canHandleProperty(sProperty)

ComponentFixture handles the 'opened' property.
Parameters:
Name Type Description
sProperty String name of the property
Implements:
See:
  • br.test.Fixture#canHandleProperty

doGiven(sProperty, vValue)

This method creates and opens the component created, and sets it on the presentation model and view sub-fixtures so that tests may manipulate model properties and the view elements.
Parameters:
Name Type Description
sProperty String name of the property
vValue String value of the property
Implements:
See:
  • br.test.Fixture#doGiven

doThen(sProperty, vValue)

doThen is not supported on the ComponentFixture.
Parameters:
Name Type Description
sProperty String name of the property
vValue String value of the property
Implements:
See:
  • br.test.Fixture#doThen

doWhen(sProperty, vValue)

doWhen is not supported on the ComponentFixture.
Parameters:
Name Type Description
sProperty String name of the property
vValue String value of the property
Implements:
See:
  • br.test.Fixture#doWhen

getComponent()

Returns the Component under test.

onOpen(fCallback)

This method can be called to set a single function on the fixture which will be executed whenever the component is created and opened.
Parameters:
Name Type Description
fCallback function the function to execute on opening the component

setSelectorMappings(selectorMappings)

Set the selector mappings to use with the view fixture. This method proxies the call to the module:br/test/ViewFixture#setSelectorMappings method.
Parameters:
Name Type Description
selectorMappings Object Map of selector mappings.

setUp()

Upon set-up of the ComponentFixture, the ComponentFactory is configured not to create an ErrorComponent. If no component can be created with the given XML configuration, an exception will be thrown instead.
Implements:
See:
  • br.test.Fixture#setUp

tearDown()

Upon tear-down of the ComponentFixture, the component created is closed and the ComponentFactory is re-configured to its original settings.
Implements:
See:
  • br.test.Fixture#tearDown

tearDownOldComponentAndRecreateWithNewXML(sXml)

Tear down this fixture and and recreate the component with the passed in xml string.
Parameters:
Name Type Description
sXml String the xml string for the component.