new module:ct-presenter /testing /Presenter Component Fixture(sTemplate Id, sPresentation Model)
Constructs a PresenterComponentFixture
.
The PresenterComponentFixture
serves to create presenter components in order to test the
component behaviour.
Tests may use the PresenterComponentFixture
to:
- create a presenter component to test the model behaviour:
given("component.opened = true")
and(component presentation model is in state A)
when(component presentation model is modified)
then(component presentation model is in new state B)
- create a presenter component and bind it (using presenter-knockout) to the view template, to test the model and view behaviour:
given("component.viewOpened = true")
and(component presentation model is in state A)
and(component view is in state X)
when(button clicked on component view)
then(component presentation model is in new state B)
and(component view is in new state Y)
Extends:
Parameters:
Name | Type | Description |
---|---|---|
sTemplateId |
String | the HTML template id representing the view of the presenter component. Required, not-null. |
sPresentationModel |
String | the presentation model class name for the presenter component. Required, not-null. |
Extends
Methods
add Sub Fixtures()
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 themodule:ct-component/frame/ComponentFrame
housing the component
- Inherited From:
- Implements:
- See:
add View Fixture Handlers(view Handlers Map)
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 |
can Handle Exact Match()
- Inherited From:
- See:
-
- module:br-test/Fixture#canHandleExactMatch
can Handle Property(sProperty)
PresenterComponentFixture handles properties 'opened' and 'viewOpened'.
Parameters:
Name | Type | Description |
---|---|---|
sProperty |
String | The property to check. |
- Overrides:
- See:
do Given(sProperty, vValue)
This method creates the presenter component (if property = 'opened') and binds it to the view template (if property = 'viewOpened') using the references to the template Id and presentation model provided in the constructor.
Parameters:
Name | Type | Description |
---|---|---|
sProperty |
String | The property name |
vValue |
Variant | The value to check. |
do Then(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 |
- Inherited From:
- Implements:
- See:
do When(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 |
- Inherited From:
- Implements:
- See:
get Component()
Returns the Component under test.
- Inherited From:
on Open(callback)
This method can be called to set a function on the fixture which will be executed whenever the component is created and opened.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | the function to execute on opening the component |
- Inherited From:
set PMMappings()
Parameters:
Name | Type | Description |
---|---|---|
mappings. |
Object |
set Selector Mappings(selector Mappings)
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. |
- Inherited From:
set Up()
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.
- Inherited From:
- Implements:
- See:
tear Down()
Upon tear-down of the ComponentFixture, the component created is closed and the ComponentFactory is re-configured to its original settings.
- Inherited From:
- Implements:
- See:
tear Down Old Component And Recreate With New XML(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. |