Caplin Trader 5.1.0

Class: module:br-test/ViewFixture

module:br-test/ViewFixture(viewSelector)

new module:br-test/ViewFixture(viewSelector)

Constructs a ViewFixture.

Parameters:
Name Type Description
viewSelector String

(optional) CSS selector to identify the parent view element for this fixture

Implements:

Methods

addViewHandlers(viewHandlersMap)

Allows custom view handlers to be added.

Parameters:
Name Type Description
viewHandlersMap Map

A map of handler name to handler class constructor reference.

Throws:

If an attempt is made to override an existing handler.

Type
br/Errors.InvalidParametersError

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)

This method is called in order to manipulate a property on the system under test in a given clause.

Parameters:
Name Type Description
propertyName String

The property to be changed.

value String

The new value of the property.

Implements:

doThen(propertyName, value)

This method is called in order to assert a property's value on the system under test.

Parameters:
Name Type Description
propertyName String

The property name to assert.

value String

The value to assert.

Implements:

doWhen(propertyName, value)

This method is called in order to manipulate a property on the system under test in a when clause.

Parameters:
Name Type Description
propertyName String

The property to be changed.

value String

The new value of the property.

Implements:

setSelectorMappings(selectorMappings)

Set the selector mappings to use with this fixture.

This allows users to create a shorthand for a selector, so that the same selector doesn't need to be repeated across different tests.

Calling: viewFixture.setSelectorMappings({'my-mapping': '.some .selector'}); then allows you to use that mapping in the test: then("form.view.(my-mapping).text = 'foo'");.

Parameters:
Name Type Description
selectorMappings Object

Map of selector mappings.

setUp()

This method is called just before a GWT test. This optional interface method can be implemented if the fixture is required to correctly set up the system-under-test before each test.

Implements:

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:

module:br-test/ViewFixture()

The ViewFixture enables interacting with the rendered view via ViewFixtureHandlers. An element in the view can be selected with selectors. In Given and When phases the selected element in the view as well as its desired value will be passed as arguments to the set() method of a ViewFixtureHandler which will update the element accordingly. In the Then phase the same arguments will be passed to the get() method of a ViewFixtureHandler, which will then inspect the selected view element and return a value of a particular property of this element to the ViewFixture. The ViewFixture should mainly be used to check that the bindings between view elements in templates and the corresponding presentation model properties have been specified correctly. A test might set a value on the view element in the Given or When phases and then check in the Then phase that this value has been updated after updating the relevant presentation model property.

Assuming that the ViewFixture has been added with the identifier view as a subfixture of the ComponentFixture which has the identifier form, then the ViewFixture can be used in the following way in a test:

then("form.view.(.orderSummary [identifier=\'orderStatus\']).text = 'complete'");

In the above example the selector for the element in the view is .spotGeneralSummary [identifier=\'dealSubmittedFor\'] and it must be specified within parentheses. The following part of the statement, .text = 'test phrase', specifies the ViewFixtureHandler (Text) and the value ('test phrase') which will be passed to it. The Text ViewFixtureHandler will then get the text value of the selected view element and return this value to the ViewFixture. The test will pass if the text value of the selected view element is indeed equal to 'test phrase'.

Constructor

new module:br-test/ViewFixture()

Methods

addViewHandlers(viewHandlersMap)

Allows custom view handlers to be added.

Parameters:
Name Type Description
viewHandlersMap Map

A map of handler name to handler class constructor reference.

Throws:

If an attempt is made to override an existing handler.

Type
br/Errors.InvalidParametersError

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)

This method is called in order to manipulate a property on the system under test in a given clause.

Parameters:
Name Type Description
propertyName String

The property to be changed.

value String

The new value of the property.

Implements:

doThen(propertyName, value)

This method is called in order to assert a property's value on the system under test.

Parameters:
Name Type Description
propertyName String

The property name to assert.

value String

The value to assert.

Implements:

doWhen(propertyName, value)

This method is called in order to manipulate a property on the system under test in a when clause.

Parameters:
Name Type Description
propertyName String

The property to be changed.

value String

The new value of the property.

Implements:

setSelectorMappings(selectorMappings)

Set the selector mappings to use with this fixture.

This allows users to create a shorthand for a selector, so that the same selector doesn't need to be repeated across different tests.

Calling: viewFixture.setSelectorMappings({'my-mapping': '.some .selector'}); then allows you to use that mapping in the test: then("form.view.(my-mapping).text = 'foo'");.

Parameters:
Name Type Description
selectorMappings Object

Map of selector mappings.

setUp()

This method is called just before a GWT test. This optional interface method can be implemented if the fixture is required to correctly set up the system-under-test before each test.

Implements:

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: