Skip to content

Commit 9ef44ef

Browse files
test(e2e): Added e2e tests
1 parent bbf31e9 commit 9ef44ef

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

e2e/app.e2e-spec.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,32 @@ describe('quickstart-angular App', () => {
99

1010
it('should display welcome message', () => {
1111
page.navigateTo();
12-
expect(page.getParagraphText()).toEqual('Welcome to app!');
12+
expect(page.getParagraphText()).toEqual('Welcome to ui-router!');
13+
});
14+
15+
it('should render 3 links', () => {
16+
page.navigateTo();
17+
expect(page.getLinks().count()).toEqual(3);
18+
});
19+
20+
it('should render Hello state', () => {
21+
page.navigateTo();
22+
page.getLink('Hello').click();
23+
expect(page.getUrl()).toEqual('/hello');
24+
expect(page.getViewContent()).toEqual('hello works!');
25+
});
26+
27+
it('should render World state', () => {
28+
page.navigateTo();
29+
page.getLink('World').click();
30+
expect(page.getUrl()).toEqual('/world');
31+
expect(page.getViewContent()).toEqual('world works!');
32+
});
33+
34+
it('should render World.nest state', () => {
35+
page.navigateTo();
36+
page.getLink('World.nest').click();
37+
expect(page.getUrl()).toEqual('/world/nest');
38+
expect(page.getViewContent()).toEqual('world works!\nnest works!');
1339
});
1440
});

e2e/app.po.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,23 @@ export class AppPage {
55
return browser.get('/');
66
}
77

8+
getUrl() {
9+
return browser.getCurrentUrl().then(result => result.replace(/^http:..[^/]*/, ''));
10+
}
11+
812
getParagraphText() {
913
return element(by.css('app-root h1')).getText();
1014
}
15+
16+
getLinks() {
17+
return element.all(by.tagName('a'));
18+
}
19+
20+
getLink(text: string) {
21+
return element.all(by.linkText(text));
22+
}
23+
24+
getViewContent() {
25+
return element.all(by.tagName('ui-view')).first().getText();
26+
}
1127
}

src/app/app.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<a uiSref="hello" uiSrefActive="active">Hello</a>
22
<a uiSref="world" uiSrefActive="active">World</a>
33
<a uiSref="world.nest" uiSrefActive="active">World.nest</a>
4+
5+
<h1>Welcome to ui-router!</h1>
6+
47
<ui-view></ui-view>

0 commit comments

Comments
 (0)