2015-10-09 13:33:12 -04:00
include ../../../../_includes/_util-fns
2015-11-10 13:31:46 -05:00
:marked
2015-10-09 13:33:12 -04:00
We’ ll need an Angular application to test, one as simple as possible while having all the angular features we want to test.
2015-10-10 06:29:34 -04:00
<!-- TODO We have such an app that you can download [here](./#). -->It’ s a one-screen variation on the “Tour of Heroes” that should be familiar to you as a reader of this Developers Guide.
2015-10-09 13:33:12 -04:00
Our test app displays a list of heroes - all favorites of the user named “Bongo”. It looks like this:
figure.image-display
2015-10-10 06:29:34 -04:00
img(src='/resources/images/devguide/application-under-test/bongos-heroes.png'
style="width:400px;" alt="Bongo's Heroes")
2015-10-09 13:33:12 -04:00
2015-11-10 13:31:46 -05:00
:marked
2015-10-09 13:33:12 -04:00
At the top is a master list of heroes; at the bottom the detail for the current hero. Click a hero in the list to change the current hero. Change the name in the textbox and that name updates everywhere. The *Update* button modifies the `Hero.name` in an arbitrary way and that change also propagates everywhere on screen. The *Delete* button deletes the hero from the list and a new hero becomes current. *Refresh* clears both the list and detail, then restores the original list of heroes.
2015-10-10 06:29:34 -04:00
<!-- TODO You can see a short video of the app in action [here](./#) -->
2015-10-09 13:33:12 -04:00
This simple app illustrates a number of Angular features that we’ d like to test.
- A simple service that presents the `username` (“Bongo”)
- A dataservice that fetches and caches the list of heroes.
- The dataservice depends in turn on another “backend” service that handles the interaction with a remote web api
- A master `HeroesComponent` presents the list
- The master communicates with a detail component `HeroDetailComponent` about the current hero both through an attribute and an event.
- The detail’ s template is nested within the master component’ s template.
- The `name` textbox illustrates two-way databinding
- The update button demonstrates that a programmatic change to the databound model propagates to both component views
- The delete button triggers an event that is caught by the parent component
2015-10-10 06:29:34 -04:00
<!-- TODO - [TBD: need to add a filter and a directive to this sample] -->
<!-- TODO - [TBD: need to shoehorn the router in somehow] -->
2015-10-09 13:33:12 -04:00
We’ ll examine the implementation details as we evolve our tests.
2015-10-16 04:06:56 -04:00
.l-main-section
2015-11-10 13:31:46 -05:00
:marked
2015-10-09 13:33:12 -04:00
## What’ s Next?
Now that we’ re familiar with how the test app works, we’ re ready to poke at it with our first application tests written in Jasmine.