Skip to content

Commit

Permalink
step-5 Filtering Repeaters
Browse files Browse the repository at this point in the history
- Add a search box to demonstrate:
  - How the data-binding works on input fields.
  - How to use the `filter` filter.
  - How `ngRepeat` automatically shrinks and grows the number of phones in the view.
- Add an end-to-end test to:
  - Show how end-to-end tests are written and used.
  - Prove that the search box and the repeater are correctly wired together.
  • Loading branch information
gkalpak authored and petebacondarwin committed Jul 7, 2016
1 parent 401ee34 commit 5da7558
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
27 changes: 21 additions & 6 deletions app/phone-list/phone-list.template.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
<ul>
<li ng-repeat="phone in $ctrl.phones">
<span>{{phone.name}}</span>
<p>{{phone.snippet}}</p>
</li>
</ul>
<div class="container-fluid">
<div class="row">
<div class="col-md-2">
<!--Sidebar content-->

Search: <input ng-model="$ctrl.query" />

</div>
<div class="col-md-10">
<!--Body content-->

<ul class="phones">
<li ng-repeat="phone in $ctrl.phones | filter:$ctrl.query">
<span>{{phone.name}}</span>
<p>{{phone.snippet}}</p>
</li>
</ul>

</div>
</div>
</div>
24 changes: 21 additions & 3 deletions e2e-tests/scenarios.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,28 @@
// Angular E2E Testing Guide:
// https://docs.angularjs.org/guide/e2e-testing

describe('My app', function() {
describe('PhoneCat Application', function() {

describe('phoneList', function() {

beforeEach(function() {
browser.get('index.html');
});

it('should filter the phone list as a user types into the search box', function() {
var phoneList = element.all(by.repeater('phone in $ctrl.phones'));
var query = element(by.model('$ctrl.query'));

expect(phoneList.count()).toBe(3);

query.sendKeys('nexus');
expect(phoneList.count()).toBe(1);

query.clear();
query.sendKeys('motorola');
expect(phoneList.count()).toBe(2);
});

beforeEach(function() {
browser.get('index.html');
});

});

0 comments on commit 5da7558

Please sign in to comment.