Constructor
new View(definition)
A View extends a Component
Parameters:
Name | Type | Description |
---|---|---|
definition |
View~ViewDefinition | definition for the view to be created |
- Mixes In:
- Source:
Methods
$component(component, definitionopt) → {Component}
Copy an existing component onto this component.
The locator for the copied component and its children will become relative to this component.
Warning: this method also copies any methods, which may still have reference to the original component.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
component |
Component | ||
definition |
Component~ComponentDefinition |
<optional> |
- Mixes In:
- Source:
Throws:
-
If first argument is not a Component
- Type
- Error
Returns:
A deep copy of the component
- Type
- Component
$hierarchy() → {Array.<(Component|View|Page)>}
Travels up the Component tree and returns an array containing the
Component and all of its parents, in the order found.
- Mixes In:
- Source:
Returns:
at()
Performs an expectation testing that the current route matches the path set for this View
- Source:
Example
it('should do something', function(){ myView.at(); });
goTo(routeParams, queryParams)
Navigates to the path for this View given the appropriate route parameters.
Query params may also be added.
Parameters:
Name | Type | Description |
---|---|---|
routeParams |
Object | a map of replacements for path parameters |
queryParams |
Object | a map of url query parameters |
- Source:
Example
<pre>
view.$path = 'http://localhost/myview/:id/posts'
// http://localhost/myview/my-101-id/posts
view.goTo({id: 'my-101-id'});
// http://localhost/myview/my-101-id/posts?state=no_posts
view.goTo({id: 'my-101-id'}, {state: 'no_posts');
</pre>
Type Definitions
ViewDefinition
The definition object for a View
Type:
- Object
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
name |
String | the name of the page |
|
locator |
String | the locator for this page (can be a css selector or a ProtractorBy locator) |
|
components |
Array.<Component~ComponentDefinition> |
<optional> |
components to add to this View |
- Source: