Skip to content

Commit 5035a42

Browse files
ttowncompiledtbosch
authored andcommitted
refactor(examples/e2e_test): Ts'ifying examples/e2_test
Translate AtScript in examples/e2e_test to TypeScript. Closes angular#2294
1 parent 4015037 commit 5035a42

21 files changed

+115
-80
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
library examples.e2e_test.hello_world.hello_world_spec;
2+
3+
main() {
4+
5+
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
var testUtil = require('angular2/src/test_lib/e2e_util');
2-
describe('hello world', function () {
1+
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
32

4-
afterEach(testUtil.verifyNoBrowserErrors);
3+
describe('hello world', function() {
4+
5+
afterEach(verifyNoBrowserErrors);
56

67
describe('static reflection', function() {
78
var URL = 'examples/src/hello_world/index.html';
89

910
it('should greet', function() {
1011
browser.get(URL);
1112

12-
expect(getComponentText('hello-app', '.greeting')).toBe('hello world!');
13+
expect(getComponentText('hello-app', '.greeting')).toEqual('hello world!');
1314
});
1415

1516
it('should change greeting', function() {
1617
browser.get(URL);
1718

1819
clickComponentButton('hello-app', '.changeButton');
19-
expect(getComponentText('hello-app', '.greeting')).toBe('howdy world!');
20+
expect(getComponentText('hello-app', '.greeting')).toEqual('howdy world!');
2021
});
2122
});
2223

@@ -26,23 +27,25 @@ describe('hello world', function () {
2627
it('should greet', function() {
2728
browser.get(URL);
2829

29-
expect(getComponentText('hello-app', '.greeting')).toBe('hello world!');
30+
expect(getComponentText('hello-app', '.greeting')).toEqual('hello world!');
3031
});
3132

3233
it('should change greeting', function() {
3334
browser.get(URL);
3435

3536
clickComponentButton('hello-app', '.changeButton');
36-
expect(getComponentText('hello-app', '.greeting')).toBe('howdy world!');
37+
expect(getComponentText('hello-app', '.greeting')).toEqual('howdy world!');
3738
});
3839
});
3940

4041
});
4142

4243
function getComponentText(selector, innerSelector) {
43-
return browser.executeScript('return document.querySelector("'+selector+'").querySelector("'+innerSelector+'").textContent');
44+
return browser.executeScript('return document.querySelector("' + selector + '").querySelector("' +
45+
innerSelector + '").textContent');
4446
}
4547

4648
function clickComponentButton(selector, innerSelector) {
47-
return browser.executeScript('return document.querySelector("'+selector+'").querySelector("'+innerSelector+'").click()');
49+
return browser.executeScript('return document.querySelector("' + selector + '").querySelector("' +
50+
innerSelector + '").click()');
4851
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
library examples.e2e_test.key_events.key_events_spec;
2+
3+
main() {
4+
5+
}

modules/examples/e2e_test/key_events/key_events_spec.es6 renamed to modules/examples/e2e_test/key_events/key_events_spec.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,52 @@
1-
var testUtil = require('angular2/src/test_lib/e2e_util');
2-
describe('key_events', function () {
1+
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
2+
3+
describe('key_events', function() {
34

45
var URL = 'examples/src/key_events/index.html';
56

6-
afterEach(testUtil.verifyNoBrowserErrors);
7-
beforeEach(() => {
8-
browser.get(URL);
9-
});
7+
afterEach(verifyNoBrowserErrors);
8+
beforeEach(() => { browser.get(URL); });
109

1110
it('should display correct key names', function() {
1211
var firstArea = element.all(by.css('.sample-area')).get(0);
13-
expect(firstArea.getText()).toBe('(none)');
12+
expect(firstArea.getText()).toEqual('(none)');
1413

1514
// testing different key categories:
1615
firstArea.sendKeys(protractor.Key.ENTER);
17-
expect(firstArea.getText()).toBe('enter');
16+
expect(firstArea.getText()).toEqual('enter');
1817

1918
firstArea.sendKeys(protractor.Key.SHIFT, protractor.Key.ENTER);
20-
expect(firstArea.getText()).toBe('shift.enter');
19+
expect(firstArea.getText()).toEqual('shift.enter');
2120

2221
firstArea.sendKeys(protractor.Key.CONTROL, protractor.Key.SHIFT, protractor.Key.ENTER);
23-
expect(firstArea.getText()).toBe('control.shift.enter');
22+
expect(firstArea.getText()).toEqual('control.shift.enter');
2423

2524
firstArea.sendKeys(' ');
26-
expect(firstArea.getText()).toBe('space');
25+
expect(firstArea.getText()).toEqual('space');
2726

2827
// It would not work with a letter which position depends on the keyboard layout (ie AZERTY vs
2928
// QWERTY), see https://code.google.com/p/chromedriver/issues/detail?id=553
3029
firstArea.sendKeys('u');
31-
expect(firstArea.getText()).toBe('u');
30+
expect(firstArea.getText()).toEqual('u');
3231

3332
firstArea.sendKeys(protractor.Key.CONTROL, 'b');
34-
expect(firstArea.getText()).toBe('control.b');
33+
expect(firstArea.getText()).toEqual('control.b');
3534

3635
firstArea.sendKeys(protractor.Key.F1);
37-
expect(firstArea.getText()).toBe('f1');
36+
expect(firstArea.getText()).toEqual('f1');
3837

3938
firstArea.sendKeys(protractor.Key.ALT, protractor.Key.F1);
40-
expect(firstArea.getText()).toBe('alt.f1');
39+
expect(firstArea.getText()).toEqual('alt.f1');
4140

4241
firstArea.sendKeys(protractor.Key.CONTROL, protractor.Key.F1);
43-
expect(firstArea.getText()).toBe('control.f1');
42+
expect(firstArea.getText()).toEqual('control.f1');
4443

4544
// There is an issue with protractor.Key.NUMPAD0 (and other NUMPADx):
4645
// chromedriver does not correctly set the location property on the event to
4746
// specify that the key is on the numeric keypad (event.location = 3)
4847
// so the following test fails:
4948
// firstArea.sendKeys(protractor.Key.NUMPAD0);
50-
// expect(firstArea.getText()).toBe('0');
49+
// expect(firstArea.getText()).toEqual('0');
5150
});
5251

5352
it('should correctly react to the specified key', function() {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
library examples.e2e_test.material.button_spec;
2+
3+
main() {}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
var testUtil = require('angular2/src/test_lib/e2e_util');
1+
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
22

3-
describe('md-button', function () {
3+
describe('md-button', function() {
44
var url = 'examples/src/material/button/index.html';
55

66
beforeEach(() => { browser.get(url); });
7-
afterEach(testUtil.verifyNoBrowserErrors);
7+
afterEach(verifyNoBrowserErrors);
88

99
// Buttons are broken right now, see https://github.com/angular/angular/issues/1602
1010
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
library examples.e2e_test.material.checkbox_spec;
2+
3+
main() {}

modules/examples/e2e_test/material/checkbox_spec.es6

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
2+
3+
describe('md-checkbox', function() {
4+
var url = 'examples/src/material/checkbox/index.html';
5+
6+
beforeEach(() => { browser.get(url); });
7+
afterEach(verifyNoBrowserErrors);
8+
9+
it('should toggle a checkbox', function() {
10+
var checkbox = element.all(by.css('md-checkbox')).first();
11+
12+
checkbox.click();
13+
expect(checkbox.getAttribute('aria-checked')).toEqual('true');
14+
15+
checkbox.click();
16+
expect(checkbox.getAttribute('aria-checked')).toEqual('false');
17+
});
18+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
library examples.e2e_test.material.dialog_spec;
2+
3+
main() {}

0 commit comments

Comments
 (0)