Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 1071c2c

Browse files
step-3 interactive search
- Added a search box to demonstrate how: - the data-binding works on input fields - to use [filter] filter - [ngRepeat] automatically shrinks and grows the number of phones in the view - Added an end-to-end test to: - show how end-to-end tests are written and used - to prove that the search box and the repeater are correctly wired together
1 parent 88615c8 commit 1071c2c

File tree

2 files changed

+43
-10
lines changed

2 files changed

+43
-10
lines changed

app/index.html

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,27 @@
1010
</head>
1111
<body ng-controller="PhoneListCtrl">
1212

13-
<ul>
14-
<li ng-repeat="phone in phones">
15-
<span>{{phone.name}}</span>
16-
<p>{{phone.snippet}}</p>
17-
</li>
18-
</ul>
13+
<div class="container-fluid">
14+
<div class="row">
15+
<div class="col-md-2">
16+
<!--Sidebar content-->
17+
18+
Search: <input ng-model="query">
19+
20+
</div>
21+
<div class="col-md-10">
22+
<!--Body content-->
23+
24+
<ul class="phones">
25+
<li ng-repeat="phone in phones | filter:query">
26+
<span>{{phone.name}}</span>
27+
<p>{{phone.snippet}}</p>
28+
</li>
29+
</ul>
30+
31+
</div>
32+
</div>
33+
</div>
1934

2035
</body>
2136
</html>

test/e2e/scenarios.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,28 @@
22

33
/* http://docs.angularjs.org/guide/dev_guide.e2e-testing */
44

5-
describe('my app', function() {
5+
describe('PhoneCat App', function() {
66

7-
beforeEach(function() {
8-
browser.get('app/index.html');
9-
});
7+
describe('Phone list view', function() {
8+
9+
beforeEach(function() {
10+
browser.get('app/index.html');
11+
});
12+
13+
14+
it('should filter the phone list as a user types into the search box', function() {
1015

16+
var phoneList = element.all(by.repeater('phone in phones'));
17+
var query = element(by.model('query'));
18+
19+
expect(phoneList.count()).toBe(3);
20+
21+
query.sendKeys('nexus');
22+
expect(phoneList.count()).toBe(1);
23+
24+
query.clear();
25+
query.sendKeys('motorola');
26+
expect(phoneList.count()).toBe(2);
27+
});
28+
});
1129
});

0 commit comments

Comments
 (0)