Class
caplin.dom.testing

ViewFixture

The ViewFixture enables interacting with the rendered view via ViewFixtureHandlers. An element in the view can be selected with jQuery 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 ticket, then the ViewFixture can be used in the following way in a test:

then('ticket.view.(.spotGeneralSummary [identifier=\'dealSubmittedFor\']).text = 'test phrase'');

In the above example the jQuery 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 Summary

Attributes Name and Description
caplin.dom.testing.ViewFixture(String sViewSelector)

Method Summary

Attributes Name and Description
void addViewHandlers(Map viewHandlersMap)

Allows custom view handlers to be added.

Methods implemented from class caplin.testing.Fixture:
addSubFixtures, canHandleProperty, doGiven, doThen, doWhen, setUp, tearDown

Constructor Detail

caplin.dom.testing.ViewFixture(String sViewSelector)

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

Method Detail

void addViewHandlers(Map viewHandlersMap)

Allows custom view handlers to be added.

Parameters
Map viewHandlersMap A map of handler name to handler class constructor reference
Throws
caplin.core.Error.INVALID_PARAMETERS
If an attempt is made to override an existing handler.