Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit c2c3177

Browse files
Foxandxsswardbell
authored andcommitted
chore: convert all e2e specs to typescript
1 parent 14ab2c5 commit c2c3177

File tree

18 files changed

+42
-152
lines changed

18 files changed

+42
-152
lines changed

public/docs/_examples/architecture/e2e-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ describe('Architecture', function () {
77
browser.get('');
88
});
99

10-
function itReset(name: string, func: (v: void) => any) {
10+
function itReset(name: string, func: () => any) {
1111
it(name, function() {
1212
browser.get('').then(func);
1313
});
1414
}
1515

16-
it('should display correct title: ' + title, function () {
16+
it(`should display correct title: ${title}`, function () {
1717
expect(element(by.css('h2')).getText()).toEqual(title);
1818
});
1919

public/docs/_examples/attribute-directives/e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('Attribute directives', function () {
77
browser.get('');
88
});
99

10-
it('should display correct title: ' + _title, function () {
10+
it(`should display correct title: ${_title}`, function () {
1111
expect(element(by.css('h1')).getText()).toEqual(_title);
1212
});
1313

public/docs/_examples/hierarchical-dependency-injection/e2e-spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,18 @@ describe('Hierarchical dependency injection', function () {
2929
testEdit(false);
3030
});
3131

32-
function testEdit(shouldSave) {
33-
let inputEle;
32+
function testEdit(shouldSave: boolean) {
3433
// select 2nd ele
3534
let heroEle = element.all(by.css('heroes-list li')).get(1);
3635
// get the 2nd span which is the name of the hero
3736
let heroNameEle = heroEle.all(by.css('hero-card span')).get(1);
3837
let editButtonEle = heroEle.element(by.cssContainingText('button','edit'));
3938
editButtonEle.click().then(function() {
40-
inputEle = heroEle.element(by.css('hero-editor input'));
39+
let inputEle = heroEle.element(by.css('hero-editor input'));
4140
// return inputEle.sendKeys("foo");
4241
return sendKeys(inputEle, "foo");
4342
}).then(function() {
44-
buttonName = shouldSave ? 'save' : 'cancel';
43+
let buttonName = shouldSave ? 'save' : 'cancel';
4544
let buttonEle = heroEle.element(by.cssContainingText('button', buttonName));
4645
return buttonEle.click();
4746
}).then(function() {

public/docs/_examples/homepage-hello-world/e2e-spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@ describe('Homepage Hello World', function () {
77

88
// Does it even launch?
99
let expectedLabel = 'Name:';
10-
it('should display the label: ' + expectedLabel, function () {
10+
it(`should display the label: ${expectedLabel}`, function () {
1111
expect(element(by.css('label')).getText()).toEqual(expectedLabel);
1212
});
1313

1414
it('should display entered name', function () {
1515
let testName = 'Bobby Joe';
16-
let newValue;
1716
let nameEle = element.all(by.css('input')).get(0);
1817
nameEle.getAttribute('value').then(function(value) {
1918
// nameEle.sendKeys(testName); // should work but doesn't
2019
sendKeys(nameEle, testName); // utility that does work
21-
newValue = value + testName; // old input box value + new name
20+
let newValue = value + testName; // old input box value + new name
2221
expect(nameEle.getAttribute('value')).toEqual(newValue);
2322
}).then(function() {
2423
// Check the interpolated message built from name

public/docs/_examples/homepage-tabs/e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('Homepage Tabs', function () {
77

88
// Does it even launch?
99
let expectedAppTitle = 'Tabs Demo';
10-
it('should display app title: ' + expectedAppTitle, function () {
10+
it(`should display app title: ${expectedAppTitle}`, function () {
1111
expect(element(by.css('h4')).getText()).toEqual(expectedAppTitle);
1212
});
1313

public/docs/_examples/homepage-todo/e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('Homepage Todo', function () {
77

88
// Does it even launch?
99
let expectedAppTitle = 'Todo';
10-
it('should display app title: ' + expectedAppTitle, function () {
10+
it(`should display app title: ${expectedAppTitle}`, function () {
1111
expect(element(by.css('h2')).getText()).toEqual(expectedAppTitle);
1212
});
1313

public/docs/_examples/lifecycle-hooks/e2e-spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('Lifecycle hooks', function () {
6161
let powerInputEle = inputEles.get(0);
6262
let titleEle = doCheckViewEle.element(by.css('p'));
6363
let changeLogEles = doCheckViewEle.all(by.css('div'));
64-
let logCount;
64+
let logCount: number;
6565

6666
expect(titleEle.getText()).toContain('Windstorm can sing');
6767
changeLogEles.count().then(function(count) {
@@ -92,7 +92,7 @@ describe('Lifecycle hooks', function () {
9292
let commentEle = parentEle.element(by.className('comment'));
9393
let logEles = parentEle.all(by.css('h4 ~ div'));
9494
let childViewInputEle = parentEle.element(by.css('my-child input'));
95-
let logCount;
95+
let logCount: number;
9696

9797
expect(childViewInputEle.getAttribute('value')).toContain('Magneta');
9898
expect(commentEle.isPresent()).toBe(false, 'comment should not be in DOM');
@@ -121,7 +121,7 @@ describe('Lifecycle hooks', function () {
121121
let commentEle = parentEle.element(by.className('comment'));
122122
let logEles = parentEle.all(by.css('h4 ~ div'));
123123
let childViewInputEle = parentEle.element(by.css('my-child input'));
124-
let logCount;
124+
let logCount: number;
125125

126126
expect(childViewInputEle.getAttribute('value')).toContain('Magneta');
127127
expect(commentEle.isPresent()).toBe(false, 'comment should not be in DOM');

public/docs/_examples/pipes/e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('Pipes', function () {
6565

6666
it('should support flying heroes (pure) ', function () {
6767
let nameEle = element(by.css('flying-heroes input[type="text"]'));
68-
let canFlyCheckEle = element(by.css('flying-heroes #can-fly'));
68+
let canFlyCheckEle = element(by.css('flying-heroes #can-fly'));
6969
let mutateCheckEle = element(by.css('flying-heroes #mutate'));
7070
let resetEle = element(by.css('flying-heroes button'));
7171
let flyingHeroesEle = element.all(by.css('flying-heroes #flyers div'));

public/docs/_examples/quickstart/e2e-spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ describe('QuickStart E2E Tests', function () {
33

44
let expectedMsg = 'My First Angular 2 App';
55

6-
76
beforeEach(function () {
87
browser.get('');
98
});
109

11-
it('should display: ' + expectedMsg, function () {
10+
it(`should display: ${expectedMsg}`, function () {
1211
expect(element(by.css('h1')).getText()).toEqual(expectedMsg);
1312
});
1413

public/docs/_examples/router-deprecated/e2e-spec.js

Lines changed: 0 additions & 111 deletions
This file was deleted.

public/docs/_examples/router-deprecated/e2e-spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('Router', function () {
66
});
77

88
function getPageStruct() {
9-
hrefEles = element.all(by.css('my-app a'));
9+
let hrefEles = element.all(by.css('my-app a'));
1010

1111
return {
1212
hrefs: hrefEles,
@@ -66,7 +66,8 @@ describe('Router', function () {
6666

6767
it('should be able to edit and save details from the heroes view', function () {
6868
let page = getPageStruct();
69-
let heroEle, heroText;
69+
let heroEle: protractor.ElementFinder;
70+
let heroText: string;
7071
page.heroesHref.click().then(function() {
7172
heroEle = page.heroesList.get(4);
7273
return heroEle.getText();
@@ -90,9 +91,10 @@ describe('Router', function () {
9091
})
9192
});
9293

93-
function crisisCenterEdit(index, shouldSave) {
94+
function crisisCenterEdit(index: number, shouldSave: boolean) {
9495
let page = getPageStruct();
95-
let crisisEle, crisisText;
96+
let crisisEle: protractor.ElementFinder;
97+
let crisisText: string;
9698
page.crisisHref.click()
9799
.then(function () {
98100
crisisEle = page.crisisList.get(index);

public/docs/_examples/router/e2e-spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('Router', function () {
66
});
77

88
function getPageStruct() {
9-
hrefEles = element.all(by.css('my-app a'));
9+
let hrefEles = element.all(by.css('my-app a'));
1010

1111
return {
1212
hrefs: hrefEles,
@@ -66,7 +66,8 @@ describe('Router', function () {
6666

6767
it('should be able to edit and save details from the heroes view', function () {
6868
let page = getPageStruct();
69-
let heroEle, heroText;
69+
let heroEle: protractor.ElementFinder;
70+
let heroText: string;
7071
page.heroesHref.click().then(function() {
7172
heroEle = page.heroesList.get(4);
7273
return heroEle.getText();
@@ -90,9 +91,10 @@ describe('Router', function () {
9091
})
9192
});
9293

93-
function crisisCenterEdit(index, shouldSave) {
94+
function crisisCenterEdit(index: number, shouldSave: boolean) {
9495
let page = getPageStruct();
95-
let crisisEle, crisisText;
96+
let crisisEle: protractor.ElementFinder;
97+
let crisisText: string;
9698
page.crisisHref.click()
9799
.then(function () {
98100
crisisEle = page.crisisList.get(index);

public/docs/_examples/server-communication/e2e-spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('Server Communication', function () {
7070
});
7171
});
7272

73-
function testForRefreshedResult(keyPressed, done) {
73+
function testForRefreshedResult(keyPressed: string, done: () => void) {
7474
testForResult('my-wiki', keyPressed, false, done)
7575
}
7676
});
@@ -101,17 +101,17 @@ describe('Server Communication', function () {
101101
});
102102

103103

104-
function testForNewResult(keyPressed, done) {
104+
function testForNewResult(keyPressed: string, done: () => void) {
105105
testForResult('my-wiki-smart', keyPressed, false, done)
106106
}
107107

108-
function testForStaleResult(keyPressed, done) {
108+
function testForStaleResult(keyPressed: string, done: () => void) {
109109
testForResult('my-wiki-smart', keyPressed, true, done)
110110
}
111111

112112
});
113113

114-
function testForResult(componentTagName, keyPressed, hasListBeforeSearch, done) {
114+
function testForResult(componentTagName: string, keyPressed: string, hasListBeforeSearch: boolean, done: () => void) {
115115
let searchWait = 1000; // Wait for wikipedia but not so long that tests timeout
116116
let wikiComponent = element(by.tagName(componentTagName));
117117
expect(wikiComponent).toBeDefined('<' + componentTagName + '> must exist');

public/docs/_examples/structural-directives/e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('Structural Directives', function () {
3232
let ngIfSiblingEle = ngIfParentEle.element(by.css('heavy-loader'));
3333
let cssButtonEle = element(by.cssContainingText('button', 'show | hide'));
3434
let cssSiblingEle = cssButtonEle.element(by.xpath('..')).element(by.css('heavy-loader'));
35-
let setConditionText;
35+
let setConditionText: string;
3636
setConditionButtonEle.getText().then(function(text) {
3737
setConditionText = text;
3838
expect(ngIfButtonEle.isPresent()).toBe(true, 'should be able to find ngIfButton');

public/docs/_examples/styleguide/e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('Getting Started E2E Tests', function() {
66
let expectedMsg = 'My First Angular 2 App';
77

88
// tests shared across languages
9-
function sharedTests(basePath) {
9+
function sharedTests(basePath: string) {
1010
beforeEach(function () {
1111
browser.get(basePath + 'index.html');
1212
});

0 commit comments

Comments
 (0)