Skip to content

Commit d9f5700

Browse files
devversiontinayuangao
authored andcommitted
build: run tslint against e2e directory (#2945)
* Now runs TSLint also against the e2e/ directory. * Add comments for the different tasks in the lint file. * Refactors the screenshot e2e file to pass TSLint and also to be less nested.
1 parent 328f7ef commit d9f5700

File tree

4 files changed

+32
-28
lines changed

4 files changed

+32
-28
lines changed
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
import {browser, by, element, Key, ProtractorBy} from 'protractor';
1+
import {browser, by, element} from 'protractor';
22

33
describe('fullscreen', () => {
4-
beforeEach(() => browser.get('/fullscreen'));
54

6-
let overlayInBody = () =>
7-
browser.isElementPresent(by.css('body > .cdk-overlay-container') as ProtractorBy);
8-
let overlayInFullscreen = () =>
9-
browser.isElementPresent(by.css('#fullscreenpane > .cdk-overlay-container') as ProtractorBy);
5+
beforeEach(() => browser.get('/fullscreen'));
106

117
it('should open a dialog inside a fullscreen element and move it to the document body', () => {
128
element(by.id('fullscreen')).click();
139
element(by.id('dialog')).click();
1410

15-
overlayInFullscreen().then((isPresent: boolean) => {
16-
expect(isPresent).toBe(true);
17-
element(by.id('exitfullscreenindialog')).click();
18-
overlayInBody().then((isPresent: boolean) => {
19-
expect(isPresent).toBe(true);
20-
});
21-
});
11+
expectOverlayInFullscreen();
12+
13+
element(by.id('exitfullscreenindialog')).click();
14+
expectOverlayInBody();
2215
});
2316

2417
it('should open a dialog inside the document body and move it to a fullscreen element', () => {
2518
element(by.id('dialog')).click();
26-
overlayInBody().then((isPresent: boolean) => {
27-
expect(isPresent).toBe(true);
28-
element(by.id('fullscreenindialog')).click();
29-
overlayInFullscreen().then((isPresent: boolean) => {
30-
expect(isPresent).toBe(true);
31-
element(by.id('exitfullscreenindialog')).click();
32-
overlayInBody().then((isPresent: boolean) => {
33-
expect(isPresent).toBe(true);
34-
});
35-
});
36-
});
19+
expectOverlayInBody();
20+
21+
element(by.id('fullscreenindialog')).click();
22+
expectOverlayInFullscreen();
23+
24+
element(by.id('exitfullscreenindialog')).click();
25+
expectOverlayInBody();
3726
});
27+
28+
/** Expects the overlay container to be inside of the body element. */
29+
function expectOverlayInBody() {
30+
expect(browser.isElementPresent(by.css('body > .cdk-overlay-container'))).toBe(true);
31+
}
32+
33+
/** Expects the overlay container to be in fullscreen mode. */
34+
function expectOverlayInFullscreen() {
35+
expect(browser.isElementPresent(by.css('#fullscreenpane > .cdk-overlay-container'))).toBe(true);
36+
}
37+
3838
});

e2e/components/menu/menu.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {browser, Key, protractor} from 'protractor';
1+
import {Key, protractor} from 'protractor';
22
import {MenuPage} from './menu-page';
33
import {expectToExist, expectAlignedWith, expectFocusOn, expectLocation} from '../../util/asserts';
44
import {pressKeys} from '../../util/actions';

e2e/screenshot.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as fs from 'fs';
2-
import * as gulp from 'gulp';
32
import * as path from 'path';
43
import {browser} from 'protractor';
54

tools/gulp/tasks/lint.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import gulp = require('gulp');
22
import {execNodeTask} from '../task_helpers';
33

4-
54
gulp.task('lint', ['tslint', 'stylelint', 'madge']);
5+
6+
/** Task that runs madge to detect circular dependencies. */
67
gulp.task('madge', ['build:release'], execNodeTask('madge', ['--circular', './dist']));
8+
9+
/** Task to lint Angular Material's scss stylesheets. */
710
gulp.task('stylelint', execNodeTask(
811
'stylelint', ['src/**/*.scss', '--config', 'stylelint-config.json', '--syntax', 'scss']
912
));
10-
gulp.task('tslint', execNodeTask('tslint', ['-c', 'tslint.json', 'src/**/*.ts']));
13+
14+
/** Task to run TSLint against the e2e/ and src/ directories. */
15+
gulp.task('tslint', execNodeTask('tslint', ['-c', 'tslint.json', 'src/**/*.ts', 'e2e/**/*.ts']));

0 commit comments

Comments
 (0)