diff --git a/aio/content/examples/ajs-quick-reference/e2e/src/app.e2e-spec.ts b/aio/content/examples/ajs-quick-reference/e2e/src/app.e2e-spec.ts index cc488718ac..ae38d15d8f 100644 --- a/aio/content/examples/ajs-quick-reference/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/ajs-quick-reference/e2e/src/app.e2e-spec.ts @@ -12,7 +12,7 @@ describe('AngularJS to Angular Quick Reference Tests', () => { it('should display proper movie data', () => { // We check only a few samples - let expectedSamples: any[] = [ + const expectedSamples: any[] = [ {row: 0, column: 0, element: 'img', attr: 'src', value: 'images/hero.png', contains: true}, {row: 0, column: 2, value: 'Celeritas'}, {row: 1, column: 3, matches: /Dec 1[678], 2015/}, // absorb timezone dif; we care about date format @@ -23,18 +23,18 @@ describe('AngularJS to Angular Quick Reference Tests', () => { ]; // Go through the samples - let movieRows = getMovieRows(); + const movieRows = getMovieRows(); for (let i = 0; i < expectedSamples.length; i++) { - let sample = expectedSamples[i]; - let tableCell = movieRows.get(sample.row) + const sample = expectedSamples[i]; + const tableCell = movieRows.get(sample.row) .all(by.tagName('td')).get(sample.column); // Check the cell or its nested element - let elementToCheck = sample.element + const elementToCheck = sample.element ? tableCell.element(by.tagName(sample.element)) : tableCell; // Check element attribute or text - let valueToCheck = sample.attr + const valueToCheck = sample.attr ? elementToCheck.getAttribute(sample.attr) : elementToCheck.getText(); @@ -70,18 +70,18 @@ describe('AngularJS to Angular Quick Reference Tests', () => { }); function testImagesAreDisplayed(isDisplayed: boolean) { - let expectedMovieCount = 3; + const expectedMovieCount = 3; - let movieRows = getMovieRows(); + const movieRows = getMovieRows(); expect(movieRows.count()).toBe(expectedMovieCount); for (let i = 0; i < expectedMovieCount; i++) { - let movieImage = movieRows.get(i).element(by.css('td > img')); + const movieImage = movieRows.get(i).element(by.css('td > img')); expect(movieImage.isDisplayed()).toBe(isDisplayed); } } function testPosterButtonClick(expectedButtonText: string, isDisplayed: boolean) { - let posterButton = element(by.css('app-movie-list tr > th > button')); + const posterButton = element(by.css('app-movie-list tr > th > button')); expect(posterButton.getText()).toBe(expectedButtonText); posterButton.click().then(() => { @@ -94,10 +94,10 @@ describe('AngularJS to Angular Quick Reference Tests', () => { } function testFavoriteHero(heroName: string, expectedLabel: string) { - let movieListComp = element(by.tagName('app-movie-list')); - let heroInput = movieListComp.element(by.tagName('input')); - let favoriteHeroLabel = movieListComp.element(by.tagName('h3')); - let resultLabel = movieListComp.element(by.css('span > p')); + const movieListComp = element(by.tagName('app-movie-list')); + const heroInput = movieListComp.element(by.tagName('input')); + const favoriteHeroLabel = movieListComp.element(by.tagName('h3')); + const resultLabel = movieListComp.element(by.css('span > p')); heroInput.clear().then(() => { heroInput.sendKeys(heroName || ''); diff --git a/aio/content/examples/architecture/e2e/src/app.e2e-spec.ts b/aio/content/examples/architecture/e2e/src/app.e2e-spec.ts index 8dd1f50543..df32e14eff 100644 --- a/aio/content/examples/architecture/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/architecture/e2e/src/app.e2e-spec.ts @@ -19,7 +19,7 @@ describe('Architecture', () => { }); it(`has h2 '${expectedH2}'`, () => { - let h2 = element.all(by.css('h2')).map((elt: any) => elt.getText()); + const h2 = element.all(by.css('h2')).map((elt: any) => elt.getText()); expect(h2).toEqual(expectedH2); }); @@ -32,29 +32,29 @@ function heroTests() { const targetHero: Hero = { id: 2, name: 'Dr Nice' }; it('has the right number of heroes', () => { - let page = getPageElts(); + const page = getPageElts(); expect(page.heroes.count()).toEqual(3); }); it('has no hero details initially', () => { - let page = getPageElts(); + const page = getPageElts(); expect(page.heroDetail.isPresent()).toBeFalsy('no hero detail'); }); it('shows selected hero details', async () => { await element(by.cssContainingText('li', targetHero.name)).click(); - let page = getPageElts(); - let hero = await heroFromDetail(page.heroDetail); + const page = getPageElts(); + const hero = await heroFromDetail(page.heroDetail); expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(targetHero.name); }); it(`shows updated hero name in details`, async () => { - let input = element.all(by.css('input')).first(); + const input = element.all(by.css('input')).first(); input.sendKeys(nameSuffix); - let page = getPageElts(); - let hero = await heroFromDetail(page.heroDetail); - let newName = targetHero.name + nameSuffix; + const page = getPageElts(); + const hero = await heroFromDetail(page.heroDetail); + const newName = targetHero.name + nameSuffix; expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(newName); }); @@ -62,12 +62,12 @@ function heroTests() { function salesTaxTests() { it('has no sales tax initially', () => { - let page = getPageElts(); + const page = getPageElts(); expect(page.salesTaxDetail.isPresent()).toBeFalsy('no sales tax info'); }); it('shows sales tax', async () => { - let page = getPageElts(); + const page = getPageElts(); page.salesTaxAmountInput.sendKeys('10', protractor.Key.ENTER); expect(page.salesTaxDetail.getText()).toEqual('The sales tax is $1.00'); }); @@ -86,9 +86,9 @@ function getPageElts() { async function heroFromDetail(detail: ElementFinder): Promise { // Get hero id from the first
- let id = await detail.all(by.css('div')).first().getText(); + const id = await detail.all(by.css('div')).first().getText(); // Get name from the h2 - let name = await detail.element(by.css('h4')).getText(); + const name = await detail.element(by.css('h4')).getText(); return { id: +id.substr(id.indexOf(' ') + 1), name: name.substr(0, name.lastIndexOf(' ')), diff --git a/aio/content/examples/architecture/src/app/backend.service.ts b/aio/content/examples/architecture/src/app/backend.service.ts index 145be4cad5..3385f9e4fc 100644 --- a/aio/content/examples/architecture/src/app/backend.service.ts +++ b/aio/content/examples/architecture/src/app/backend.service.ts @@ -18,7 +18,7 @@ export class BackendService { // TODO: get from the database return Promise.resolve(HEROES); } - let err = new Error('Cannot get object of this type'); + const err = new Error('Cannot get object of this type'); this.logger.error(err); throw err; } diff --git a/aio/content/examples/architecture/src/app/sales-tax.service.ts b/aio/content/examples/architecture/src/app/sales-tax.service.ts index d859dc1595..8e92096dd6 100644 --- a/aio/content/examples/architecture/src/app/sales-tax.service.ts +++ b/aio/content/examples/architecture/src/app/sales-tax.service.ts @@ -7,7 +7,7 @@ export class SalesTaxService { constructor(private rateService: TaxRateService) { } getVAT(value: string | number) { - let amount = (typeof value === 'string') ? + const amount = (typeof value === 'string') ? parseFloat(value) : value; return (amount || 0) * this.rateService.getRate('VAT'); } diff --git a/aio/content/examples/attribute-directives/e2e/src/app.e2e-spec.ts b/aio/content/examples/attribute-directives/e2e/src/app.e2e-spec.ts index 3fc012b855..bb03f8c912 100644 --- a/aio/content/examples/attribute-directives/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/attribute-directives/e2e/src/app.e2e-spec.ts @@ -2,7 +2,7 @@ import { browser, element, by } from 'protractor'; describe('Attribute directives', () => { - let title = 'My First Attribute Directive'; + const title = 'My First Attribute Directive'; beforeAll(() => { browser.get(''); diff --git a/aio/content/examples/binding-syntax/e2e/src/app.e2e-spec.ts b/aio/content/examples/binding-syntax/e2e/src/app.e2e-spec.ts index d42d23976f..81d4cbf075 100644 --- a/aio/content/examples/binding-syntax/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/binding-syntax/e2e/src/app.e2e-spec.ts @@ -36,22 +36,22 @@ describe('Binding syntax e2e tests', () => { it('should log a message including Sarah', async () => { - let attributeButton = element.all(by.css('button')).get(1); + const attributeButton = element.all(by.css('button')).get(1); await attributeButton.click(); const contents = 'Sarah'; logChecker(attributeButton, contents); }); it('should log a message including Sarah for DOM property', async () => { - let DOMPropertyButton = element.all(by.css('button')).get(2); + const DOMPropertyButton = element.all(by.css('button')).get(2); await DOMPropertyButton.click(); const contents = 'Sarah'; logChecker(DOMPropertyButton, contents); }); it('should log a message including Sally for DOM property', async () => { - let DOMPropertyButton = element.all(by.css('button')).get(2); - let input = element(by.css('input')); + const DOMPropertyButton = element.all(by.css('button')).get(2); + const input = element(by.css('input')); input.sendKeys('Sally'); await DOMPropertyButton.click(); const contents = 'Sally'; @@ -59,14 +59,14 @@ describe('Binding syntax e2e tests', () => { }); it('should log a message that Test Button works', async () => { - let testButton = element.all(by.css('button')).get(3); + const testButton = element.all(by.css('button')).get(3); await testButton.click(); const contents = 'Test'; logChecker(testButton, contents); }); it('should toggle Test Button disabled', async () => { - let toggleButton = element.all(by.css('button')).get(4); + const toggleButton = element.all(by.css('button')).get(4); await toggleButton.click(); const contents = 'true'; logChecker(toggleButton, contents); diff --git a/aio/content/examples/binding-syntax/src/app/app.component.ts b/aio/content/examples/binding-syntax/src/app/app.component.ts index 525f175d66..0b804d8e84 100644 --- a/aio/content/examples/binding-syntax/src/app/app.component.ts +++ b/aio/content/examples/binding-syntax/src/app/app.component.ts @@ -26,7 +26,7 @@ export class AppComponent { toggleDisabled(): any { - let testButton = document.getElementById('testButton') as HTMLInputElement; + const testButton = document.getElementById('testButton') as HTMLInputElement; testButton.disabled = !testButton.disabled; console.warn(testButton.disabled); } diff --git a/aio/content/examples/built-in-directives/e2e/src/app.e2e-spec.ts b/aio/content/examples/built-in-directives/e2e/src/app.e2e-spec.ts index 4fc263e2e7..92c4640222 100644 --- a/aio/content/examples/built-in-directives/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/built-in-directives/e2e/src/app.e2e-spec.ts @@ -7,13 +7,13 @@ describe('Built-in Directives', () => { }); it('should have title Built-in Directives', () => { - let title = element.all(by.css('h1')).get(0); + const title = element.all(by.css('h1')).get(0); expect(title.getText()).toEqual('Built-in Directives'); }); it('should change first Teapot header', async () => { - let firstLabel = element.all(by.css('p')).get(0); - let firstInput = element.all(by.css('input')).get(0); + const firstLabel = element.all(by.css('p')).get(0); + const firstInput = element.all(by.css('input')).get(0); expect(firstLabel.getText()).toEqual('Current item name: Teapot'); firstInput.sendKeys('abc'); @@ -22,48 +22,48 @@ describe('Built-in Directives', () => { it('should modify sentence when modified checkbox checked', () => { - let modifiedChkbxLabel = element.all(by.css('input[type="checkbox"]')).get(1); - let modifiedSentence = element.all(by.css('div')).get(1); + const modifiedChkbxLabel = element.all(by.css('input[type="checkbox"]')).get(1); + const modifiedSentence = element.all(by.css('div')).get(1); modifiedChkbxLabel.click(); expect(modifiedSentence.getText()).toContain('modified'); }); it('should modify sentence when normal checkbox checked', () => { - let normalChkbxLabel = element.all(by.css('input[type="checkbox"]')).get(4); - let normalSentence = element.all(by.css('div')).get(7); + const normalChkbxLabel = element.all(by.css('input[type="checkbox"]')).get(4); + const normalSentence = element.all(by.css('div')).get(7); normalChkbxLabel.click(); expect(normalSentence.getText()).toContain('normal weight and, extra large'); }); it('should toggle app-item-detail', () => { - let toggleButton = element.all(by.css('button')).get(3); - let toggledDiv = element.all(by.css('app-item-detail')).get(0); + const toggleButton = element.all(by.css('button')).get(3); + const toggledDiv = element.all(by.css('app-item-detail')).get(0); toggleButton.click(); expect(toggledDiv.isDisplayed()).toBe(true); }); it('should hide app-item-detail', () => { - let hiddenMessage = element.all(by.css('p')).get(11); - let hiddenDiv = element.all(by.css('app-item-detail')).get(2); + const hiddenMessage = element.all(by.css('p')).get(11); + const hiddenDiv = element.all(by.css('app-item-detail')).get(2); expect(hiddenMessage.getText()).toContain('in the DOM'); expect(hiddenDiv.isDisplayed()).toBe(true); }); it('should have 10 lists each containing the string Teapot', () => { - let listDiv = element.all(by.cssContainingText('.box', 'Teapot')); + const listDiv = element.all(by.cssContainingText('.box', 'Teapot')); expect(listDiv.count()).toBe(10); }); it('should switch case', () => { - let tvRadioButton = element.all(by.css('input[type="radio"]')).get(3); - let tvDiv = element(by.css('app-lost-item')); + const tvRadioButton = element.all(by.css('input[type="radio"]')).get(3); + const tvDiv = element(by.css('app-lost-item')); - let fishbowlRadioButton = element.all(by.css('input[type="radio"]')).get(4); - let fishbowlDiv = element(by.css('app-unknown-item')); + const fishbowlRadioButton = element.all(by.css('input[type="radio"]')).get(4); + const fishbowlDiv = element(by.css('app-unknown-item')); tvRadioButton.click(); expect(tvDiv.getText()).toContain('Television'); diff --git a/aio/content/examples/built-in-template-functions/e2e/src/app.e2e-spec.ts b/aio/content/examples/built-in-template-functions/e2e/src/app.e2e-spec.ts index 56654667c5..a8bc7f0adf 100644 --- a/aio/content/examples/built-in-template-functions/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/built-in-template-functions/e2e/src/app.e2e-spec.ts @@ -6,12 +6,12 @@ describe('Built Template Functions Example', () => { }); it('should have title Built-in Template Functions', () => { - let title = element.all(by.css('h1')).get(0); + const title = element.all(by.css('h1')).get(0); expect(title.getText()).toEqual('Built-in Template Functions'); }); it('should display $any( ) in h2', () => { - let header = element(by.css('h2')); + const header = element(by.css('h2')); expect(header.getText()).toContain('$any( )'); }); diff --git a/aio/content/examples/component-interaction/e2e/src/app.e2e-spec.ts b/aio/content/examples/component-interaction/e2e/src/app.e2e-spec.ts index 8f0503d04c..903691f898 100644 --- a/aio/content/examples/component-interaction/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/component-interaction/e2e/src/app.e2e-spec.ts @@ -11,16 +11,16 @@ describe('Component Communication Cookbook Tests', () => { describe('Parent-to-child communication', () => { // #docregion parent-to-child // ... - let heroNames = ['Dr IQ', 'Magneta', 'Bombasto']; - let masterName = 'Master'; + const heroNames = ['Dr IQ', 'Magneta', 'Bombasto']; + const masterName = 'Master'; it('should pass properties to children properly', () => { - let parent = element.all(by.tagName('app-hero-parent')).get(0); - let heroes = parent.all(by.tagName('app-hero-child')); + const parent = element.all(by.tagName('app-hero-parent')).get(0); + const heroes = parent.all(by.tagName('app-hero-child')); for (let i = 0; i < heroNames.length; i++) { - let childTitle = heroes.get(i).element(by.tagName('h3')).getText(); - let childDetail = heroes.get(i).element(by.tagName('p')).getText(); + const childTitle = heroes.get(i).element(by.tagName('h3')).getText(); + const childDetail = heroes.get(i).element(by.tagName('p')).getText(); expect(childTitle).toEqual(heroNames[i] + ' says:'); expect(childDetail).toContain(masterName); } @@ -33,22 +33,22 @@ describe('Component Communication Cookbook Tests', () => { // #docregion parent-to-child-setter // ... it('should display trimmed, non-empty names', () => { - let nonEmptyNameIndex = 0; - let nonEmptyName = '"Dr IQ"'; - let parent = element.all(by.tagName('app-name-parent')).get(0); - let hero = parent.all(by.tagName('app-name-child')).get(nonEmptyNameIndex); + const nonEmptyNameIndex = 0; + const nonEmptyName = '"Dr IQ"'; + const parent = element.all(by.tagName('app-name-parent')).get(0); + const hero = parent.all(by.tagName('app-name-child')).get(nonEmptyNameIndex); - let displayName = hero.element(by.tagName('h3')).getText(); + const displayName = hero.element(by.tagName('h3')).getText(); expect(displayName).toEqual(nonEmptyName); }); it('should replace empty name with default name', () => { - let emptyNameIndex = 1; - let defaultName = '""'; - let parent = element.all(by.tagName('app-name-parent')).get(0); - let hero = parent.all(by.tagName('app-name-child')).get(emptyNameIndex); + const emptyNameIndex = 1; + const defaultName = '""'; + const parent = element.all(by.tagName('app-name-parent')).get(0); + const hero = parent.all(by.tagName('app-name-child')).get(emptyNameIndex); - let displayName = hero.element(by.tagName('h3')).getText(); + const displayName = hero.element(by.tagName('h3')).getText(); expect(displayName).toEqual(defaultName); }); // ... @@ -60,10 +60,10 @@ describe('Component Communication Cookbook Tests', () => { // ... // Test must all execute in this exact order it('should set expected initial values', () => { - let actual = getActual(); + const actual = getActual(); - let initialLabel = 'Version 1.23'; - let initialLog = 'Initial value of major set to 1, Initial value of minor set to 23'; + const initialLabel = 'Version 1.23'; + const initialLog = 'Initial value of major set to 1, Initial value of minor set to 23'; expect(actual.label).toBe(initialLabel); expect(actual.count).toBe(1); @@ -71,15 +71,15 @@ describe('Component Communication Cookbook Tests', () => { }); it('should set expected values after clicking \'Minor\' twice', () => { - let repoTag = element(by.tagName('app-version-parent')); - let newMinorButton = repoTag.all(by.tagName('button')).get(0); + const repoTag = element(by.tagName('app-version-parent')); + const newMinorButton = repoTag.all(by.tagName('button')).get(0); newMinorButton.click().then(() => { newMinorButton.click().then(() => { - let actual = getActual(); + const actual = getActual(); - let labelAfter2Minor = 'Version 1.25'; - let logAfter2Minor = 'minor changed from 24 to 25'; + const labelAfter2Minor = 'Version 1.25'; + const logAfter2Minor = 'minor changed from 24 to 25'; expect(actual.label).toBe(labelAfter2Minor); expect(actual.count).toBe(3); @@ -89,14 +89,14 @@ describe('Component Communication Cookbook Tests', () => { }); it('should set expected values after clicking \'Major\' once', () => { - let repoTag = element(by.tagName('app-version-parent')); - let newMajorButton = repoTag.all(by.tagName('button')).get(1); + const repoTag = element(by.tagName('app-version-parent')); + const newMajorButton = repoTag.all(by.tagName('button')).get(1); newMajorButton.click().then(() => { - let actual = getActual(); + const actual = getActual(); - let labelAfterMajor = 'Version 2.0'; - let logAfterMajor = 'major changed from 1 to 2, minor changed from 25 to 0'; + const labelAfterMajor = 'Version 2.0'; + const logAfterMajor = 'major changed from 1 to 2, minor changed from 25 to 0'; expect(actual.label).toBe(labelAfterMajor); expect(actual.count).toBe(4); @@ -105,10 +105,10 @@ describe('Component Communication Cookbook Tests', () => { }); function getActual() { - let versionTag = element(by.tagName('app-version-child')); - let label = versionTag.element(by.tagName('h3')).getText(); - let ul = versionTag.element((by.tagName('ul'))); - let logs = ul.all(by.tagName('li')); + const versionTag = element(by.tagName('app-version-child')); + const label = versionTag.element(by.tagName('h3')).getText(); + const ul = versionTag.element((by.tagName('ul'))); + const logs = ul.all(by.tagName('li')); return { label, @@ -125,26 +125,26 @@ describe('Component Communication Cookbook Tests', () => { // #docregion child-to-parent // ... it('should not emit the event initially', () => { - let voteLabel = element(by.tagName('app-vote-taker')) + const voteLabel = element(by.tagName('app-vote-taker')) .element(by.tagName('h3')).getText(); expect(voteLabel).toBe('Agree: 0, Disagree: 0'); }); it('should process Agree vote', () => { - let agreeButton1 = element.all(by.tagName('app-voter')).get(0) + const agreeButton1 = element.all(by.tagName('app-voter')).get(0) .all(by.tagName('button')).get(0); agreeButton1.click().then(() => { - let voteLabel = element(by.tagName('app-vote-taker')) + const voteLabel = element(by.tagName('app-vote-taker')) .element(by.tagName('h3')).getText(); expect(voteLabel).toBe('Agree: 1, Disagree: 0'); }); }); it('should process Disagree vote', () => { - let agreeButton1 = element.all(by.tagName('app-voter')).get(1) + const agreeButton1 = element.all(by.tagName('app-voter')).get(1) .all(by.tagName('button')).get(1); agreeButton1.click().then(() => { - let voteLabel = element(by.tagName('app-vote-taker')) + const voteLabel = element(by.tagName('app-vote-taker')) .element(by.tagName('h3')).getText(); expect(voteLabel).toBe('Agree: 1, Disagree: 1'); }); @@ -167,19 +167,19 @@ describe('Component Communication Cookbook Tests', () => { // #docregion countdown-timer-tests // ... it('timer and parent seconds should match', () => { - let parent = element(by.tagName(parentTag)); - let message = parent.element(by.tagName('app-countdown-timer')).getText(); + const parent = element(by.tagName(parentTag)); + const message = parent.element(by.tagName('app-countdown-timer')).getText(); browser.sleep(10); // give `seconds` a chance to catchup with `message` - let seconds = parent.element(by.className('seconds')).getText(); + const seconds = parent.element(by.className('seconds')).getText(); expect(message).toContain(seconds); }); it('should stop the countdown', () => { - let parent = element(by.tagName(parentTag)); - let stopButton = parent.all(by.tagName('button')).get(1); + const parent = element(by.tagName(parentTag)); + const stopButton = parent.all(by.tagName('button')).get(1); stopButton.click().then(() => { - let message = parent.element(by.tagName('app-countdown-timer')).getText(); + const message = parent.element(by.tagName('app-countdown-timer')).getText(); expect(message).toContain('Holding'); }); }); @@ -192,10 +192,10 @@ describe('Component Communication Cookbook Tests', () => { // #docregion bidirectional-service // ... it('should announce a mission', () => { - let missionControl = element(by.tagName('app-mission-control')); - let announceButton = missionControl.all(by.tagName('button')).get(0); + const missionControl = element(by.tagName('app-mission-control')); + const announceButton = missionControl.all(by.tagName('button')).get(0); announceButton.click().then(() => { - let history = missionControl.all(by.tagName('li')); + const history = missionControl.all(by.tagName('li')); expect(history.count()).toBe(1); expect(history.get(0).getText()).toMatch(/Mission.* announced/); }); @@ -214,11 +214,11 @@ describe('Component Communication Cookbook Tests', () => { }); function testConfirmMission(buttonIndex: number, expectedLogCount: number, astronaut: string) { - let confirmedLog = ' confirmed the mission'; - let missionControl = element(by.tagName('app-mission-control')); - let confirmButton = missionControl.all(by.tagName('button')).get(buttonIndex); + const confirmedLog = ' confirmed the mission'; + const missionControl = element(by.tagName('app-mission-control')); + const confirmButton = missionControl.all(by.tagName('button')).get(buttonIndex); confirmButton.click().then(() => { - let history = missionControl.all(by.tagName('li')); + const history = missionControl.all(by.tagName('li')); expect(history.count()).toBe(expectedLogCount); expect(history.get(expectedLogCount - 1).getText()).toBe(astronaut + confirmedLog); }); diff --git a/aio/content/examples/component-interaction/src/app/app.module.ts b/aio/content/examples/component-interaction/src/app/app.module.ts index 990ee7006e..d1b4570665 100644 --- a/aio/content/examples/component-interaction/src/app/app.module.ts +++ b/aio/content/examples/component-interaction/src/app/app.module.ts @@ -15,7 +15,7 @@ import { VersionParentComponent } from './version-parent.component'; import { VoterComponent } from './voter.component'; import { VoteTakerComponent } from './votetaker.component'; -let directives: any[] = [ +const directives: any[] = [ AppComponent, AstronautComponent, CountdownTimerComponent, @@ -30,7 +30,7 @@ let directives: any[] = [ VoteTakerComponent ]; -let schemas: any[] = []; +const schemas: any[] = []; // Include Countdown examples // unless in e2e tests which they break. diff --git a/aio/content/examples/component-interaction/src/app/missioncontrol.component.ts b/aio/content/examples/component-interaction/src/app/missioncontrol.component.ts index 9270d63bb0..191a619e87 100644 --- a/aio/content/examples/component-interaction/src/app/missioncontrol.component.ts +++ b/aio/content/examples/component-interaction/src/app/missioncontrol.component.ts @@ -34,7 +34,7 @@ export class MissionControlComponent { } announce() { - let mission = this.missions[this.nextMission++]; + const mission = this.missions[this.nextMission++]; this.missionService.announceMission(mission); this.history.push(`Mission "${mission}" announced`); if (this.nextMission >= this.missions.length) { this.nextMission = 0; } diff --git a/aio/content/examples/component-interaction/src/app/version-child.component.ts b/aio/content/examples/component-interaction/src/app/version-child.component.ts index 1f3da880f4..b3cecd6872 100644 --- a/aio/content/examples/component-interaction/src/app/version-child.component.ts +++ b/aio/content/examples/component-interaction/src/app/version-child.component.ts @@ -18,14 +18,14 @@ export class VersionChildComponent implements OnChanges { changeLog: string[] = []; ngOnChanges(changes: {[propKey: string]: SimpleChange}) { - let log: string[] = []; - for (let propName in changes) { - let changedProp = changes[propName]; - let to = JSON.stringify(changedProp.currentValue); + const log: string[] = []; + for (const propName in changes) { + const changedProp = changes[propName]; + const to = JSON.stringify(changedProp.currentValue); if (changedProp.isFirstChange()) { log.push(`Initial value of ${propName} set to ${to}`); } else { - let from = JSON.stringify(changedProp.previousValue); + const from = JSON.stringify(changedProp.previousValue); log.push(`${propName} changed from ${from} to ${to}`); } } diff --git a/aio/content/examples/component-styles/e2e/src/app.e2e-spec.ts b/aio/content/examples/component-styles/e2e/src/app.e2e-spec.ts index 88e83974a4..2265e95f6e 100644 --- a/aio/content/examples/component-styles/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/component-styles/e2e/src/app.e2e-spec.ts @@ -7,8 +7,8 @@ describe('Component Style Tests', () => { }); it('scopes component styles to component view', () => { - let componentH1 = element(by.css('app-root > h1')); - let externalH1 = element(by.css('body > h1')); + const componentH1 = element(by.css('app-root > h1')); + const externalH1 = element(by.css('body > h1')); // Note: sometimes webdriver returns the fontWeight as "normal", // other times as "400", both of which are equal in CSS terms. @@ -18,48 +18,48 @@ describe('Component Style Tests', () => { it('allows styling :host element', () => { - let host = element(by.css('app-hero-details')); + const host = element(by.css('app-hero-details')); expect(host.getCssValue('borderWidth')).toEqual('1px'); }); it('supports :host() in function form', () => { - let host = element(by.css('app-hero-details')); + const host = element(by.css('app-hero-details')); host.element(by.buttonText('Activate')).click(); expect(host.getCssValue('borderWidth')).toEqual('3px'); }); it('allows conditional :host-context() styling', () => { - let h2 = element(by.css('app-hero-details h2')); + const h2 = element(by.css('app-hero-details h2')); expect(h2.getCssValue('backgroundColor')).toEqual('rgba(238, 238, 255, 1)'); // #eeeeff }); it('styles both view and content children with /deep/', () => { - let viewH3 = element(by.css('app-hero-team h3')); - let contentH3 = element(by.css('app-hero-controls h3')); + const viewH3 = element(by.css('app-hero-team h3')); + const contentH3 = element(by.css('app-hero-controls h3')); expect(viewH3.getCssValue('fontStyle')).toEqual('italic'); expect(contentH3.getCssValue('fontStyle')).toEqual('italic'); }); it('includes styles loaded with CSS @import', () => { - let host = element(by.css('app-hero-details')); + const host = element(by.css('app-hero-details')); expect(host.getCssValue('padding')).toEqual('10px'); }); it('processes template inline styles', () => { - let button = element(by.css('app-hero-controls button')); - let externalButton = element(by.css('body > button')); + const button = element(by.css('app-hero-controls button')); + const externalButton = element(by.css('body > button')); expect(button.getCssValue('backgroundColor')).toEqual('rgba(255, 255, 255, 1)'); // #ffffff expect(externalButton.getCssValue('backgroundColor')).not.toEqual('rgba(255, 255, 255, 1)'); }); it('processes template s', () => { - let li = element(by.css('app-hero-team li:first-child')); - let externalLi = element(by.css('body > ul li')); + const li = element(by.css('app-hero-team li:first-child')); + const externalLi = element(by.css('body > ul li')); expect(li.getCssValue('listStyleType')).toEqual('square'); expect(externalLi.getCssValue('listStyleType')).not.toEqual('square'); diff --git a/aio/content/examples/dependency-injection-in-action/e2e/src/app.e2e-spec.ts b/aio/content/examples/dependency-injection-in-action/e2e/src/app.e2e-spec.ts index 746ecbee54..0019e51c30 100644 --- a/aio/content/examples/dependency-injection-in-action/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/dependency-injection-in-action/e2e/src/app.e2e-spec.ts @@ -7,68 +7,68 @@ describe('Dependency Injection Cookbook', () => { }); it('should render Logged in User example', () => { - let loggedInUser = element.all(by.xpath('//h3[text()="Logged in user"]')).get(0); + const loggedInUser = element.all(by.xpath('//h3[text()="Logged in user"]')).get(0); expect(loggedInUser).toBeDefined(); }); it('"Bombasto" should be the logged in user', () => { - let loggedInUser = element.all(by.xpath('//div[text()="Name: Bombasto"]')).get(0); + const loggedInUser = element.all(by.xpath('//div[text()="Name: Bombasto"]')).get(0); expect(loggedInUser).toBeDefined(); }); it('should render sorted heroes', () => { - let sortedHeroes = element.all(by.xpath('//h3[text()="Sorted Heroes" and position()=1]')).get(0); + const sortedHeroes = element.all(by.xpath('//h3[text()="Sorted Heroes" and position()=1]')).get(0); expect(sortedHeroes).toBeDefined(); }); it('Dr Nice should be in sorted heroes', () => { - let sortedHero = element.all(by.xpath('//sorted-heroes/[text()="Dr Nice" and position()=2]')).get(0); + const sortedHero = element.all(by.xpath('//sorted-heroes/[text()="Dr Nice" and position()=2]')).get(0); expect(sortedHero).toBeDefined(); }); it('RubberMan should be in sorted heroes', () => { - let sortedHero = element.all(by.xpath('//sorted-heroes/[text()="RubberMan" and position()=3]')).get(0); + const sortedHero = element.all(by.xpath('//sorted-heroes/[text()="RubberMan" and position()=3]')).get(0); expect(sortedHero).toBeDefined(); }); it('Magma should be in sorted heroes', () => { - let sortedHero = element.all(by.xpath('//sorted-heroes/[text()="Magma"]')).get(0); + const sortedHero = element.all(by.xpath('//sorted-heroes/[text()="Magma"]')).get(0); expect(sortedHero).toBeDefined(); }); it('should render Hero of the Month', () => { - let heroOfTheMonth = element.all(by.xpath('//h3[text()="Hero of the month"]')).get(0); + const heroOfTheMonth = element.all(by.xpath('//h3[text()="Hero of the month"]')).get(0); expect(heroOfTheMonth).toBeDefined(); }); it('should render Hero Bios', () => { - let heroBios = element.all(by.xpath('//h3[text()="Hero Bios"]')).get(0); + const heroBios = element.all(by.xpath('//h3[text()="Hero Bios"]')).get(0); expect(heroBios).toBeDefined(); }); it('should render Magma\'s description in Hero Bios', () => { - let magmaText = element.all(by.xpath('//textarea[text()="Hero of all trades"]')).get(0); + const magmaText = element.all(by.xpath('//textarea[text()="Hero of all trades"]')).get(0); expect(magmaText).toBeDefined(); }); it('should render Magma\'s phone in Hero Bios and Contacts', () => { - let magmaPhone = element.all(by.xpath('//div[text()="Phone #: 555-555-5555"]')).get(0); + const magmaPhone = element.all(by.xpath('//div[text()="Phone #: 555-555-5555"]')).get(0); expect(magmaPhone).toBeDefined(); }); it('should render Hero-of-the-Month runner-ups', () => { - let runnersUp = element(by.id('rups1')).getText(); + const runnersUp = element(by.id('rups1')).getText(); expect(runnersUp).toContain('RubberMan, Dr Nice'); }); it('should render DateLogger log entry in Hero-of-the-Month', () => { - let logs = element.all(by.id('logs')).get(0).getText(); + const logs = element.all(by.id('logs')).get(0).getText(); expect(logs).toContain('INFO: starting up at'); }); it('should highlight Hero Bios and Contacts container when mouseover', () => { - let target = element(by.css('div[appHighlight="yellow"]')); - let yellow = 'rgba(255, 255, 0, 1)'; + const target = element(by.css('div[appHighlight="yellow"]')); + const yellow = 'rgba(255, 255, 0, 1)'; expect(target.getCssValue('background-color')).not.toEqual(yellow); @@ -80,10 +80,10 @@ describe('Dependency Injection Cookbook', () => { }); describe('in Parent Finder', () => { - let cathy1 = element(by.css('alex cathy')); - let craig1 = element(by.css('alex craig')); - let carol1 = element(by.css('alex carol p')); - let carol2 = element(by.css('barry carol p')); + const cathy1 = element(by.css('alex cathy')); + const craig1 = element(by.css('alex craig')); + const carol1 = element(by.css('alex carol p')); + const carol2 = element(by.css('barry carol p')); it('"Cathy" should find "Alex" via the component class', () => { expect(cathy1.getText()).toContain('Found Alex via the component'); diff --git a/aio/content/examples/dependency-injection-in-action/src/app/hero-data.ts b/aio/content/examples/dependency-injection-in-action/src/app/hero-data.ts index 10cdbcaab1..98ca87160e 100644 --- a/aio/content/examples/dependency-injection-in-action/src/app/hero-data.ts +++ b/aio/content/examples/dependency-injection-in-action/src/app/hero-data.ts @@ -3,7 +3,7 @@ import { Hero } from './hero'; export class HeroData { createDb() { - let heroes = [ + const heroes = [ new Hero(1, 'Windstorm'), new Hero(2, 'Bombasto'), new Hero(3, 'Magneta'), diff --git a/aio/content/examples/dependency-injection-in-action/src/app/user-context.service.ts b/aio/content/examples/dependency-injection-in-action/src/app/user-context.service.ts index 12cefa552a..e6419c5106 100644 --- a/aio/content/examples/dependency-injection-in-action/src/app/user-context.service.ts +++ b/aio/content/examples/dependency-injection-in-action/src/app/user-context.service.ts @@ -24,7 +24,7 @@ export class UserContextService { // #enddocregion ctor, injectables loadUser(userId: number) { - let user = this.userService.getUserById(userId); + const user = this.userService.getUserById(userId); this.name = user.name; this.role = user.role; diff --git a/aio/content/examples/dependency-injection/e2e/src/app.e2e-spec.ts b/aio/content/examples/dependency-injection/e2e/src/app.e2e-spec.ts index 1bc80c4d93..81b065f625 100644 --- a/aio/content/examples/dependency-injection/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/dependency-injection/e2e/src/app.e2e-spec.ts @@ -138,15 +138,15 @@ describe('Dependency Injection Tests', () => { }); it('unauthorized user should have multiple unauthorized heroes', () => { - let heroes = element.all(by.css('#unauthorized app-hero-list div')); + const heroes = element.all(by.css('#unauthorized app-hero-list div')); expect(heroes.count()).toBeGreaterThan(0); }); it('unauthorized user should have no secret heroes', () => { - let heroes = element.all(by.css('#unauthorized app-hero-list div')); + const heroes = element.all(by.css('#unauthorized app-hero-list div')); expect(heroes.count()).toBeGreaterThan(0); - let filteredHeroes = heroes.filter((elem: ElementFinder, index: number) => { + const filteredHeroes = heroes.filter((elem: ElementFinder, index: number) => { return elem.getText().then((text: string) => /secret/.test(text)); }); @@ -160,7 +160,7 @@ describe('Dependency Injection Tests', () => { describe('after button click', () => { beforeAll((done: any) => { - let buttonEle = element.all(by.cssContainingText('button', 'Next User')).get(0); + const buttonEle = element.all(by.cssContainingText('button', 'Next User')).get(0); buttonEle.click().then(done, done); }); @@ -170,20 +170,20 @@ describe('Dependency Injection Tests', () => { }); it('authorized user should have multiple authorized heroes ', () => { - let heroes = element.all(by.css('#authorized app-hero-list div')); + const heroes = element.all(by.css('#authorized app-hero-list div')); expect(heroes.count()).toBeGreaterThan(0); }); it('authorized user should have multiple authorized heroes with tree-shakeable HeroesService', () => { - let heroes = element.all(by.css('#tspAuthorized app-hero-list div')); + const heroes = element.all(by.css('#tspAuthorized app-hero-list div')); expect(heroes.count()).toBeGreaterThan(0); }); it('authorized user should have secret heroes', () => { - let heroes = element.all(by.css('#authorized app-hero-list div')); + const heroes = element.all(by.css('#authorized app-hero-list div')); expect(heroes.count()).toBeGreaterThan(0); - let filteredHeroes = heroes.filter((elem: ElementFinder, index: number) => { + const filteredHeroes = heroes.filter((elem: ElementFinder, index: number) => { return elem.getText().then((text: string) => /secret/.test(text)); }); diff --git a/aio/content/examples/dependency-injection/src/app/car/car-creations.ts b/aio/content/examples/dependency-injection/src/app/car/car-creations.ts index 59c986a4ea..23011ee626 100644 --- a/aio/content/examples/dependency-injection/src/app/car/car-creations.ts +++ b/aio/content/examples/dependency-injection/src/app/car/car-creations.ts @@ -7,7 +7,7 @@ import { Car, Engine, Tires } from './car'; export function simpleCar() { // #docregion car-ctor-instantiation // Simple car with 4 cylinders and Flintstone tires. - let car = new Car(new Engine(), new Tires()); + const car = new Car(new Engine(), new Tires()); // #enddocregion car-ctor-instantiation car.description = 'Simple'; return car; @@ -24,8 +24,8 @@ class Engine2 { export function superCar() { // #docregion car-ctor-instantiation-with-param // Super car with 12 cylinders and Flintstone tires. - let bigCylinders = 12; - let car = new Car(new Engine2(bigCylinders), new Tires()); + const bigCylinders = 12; + const car = new Car(new Engine2(bigCylinders), new Tires()); // #enddocregion car-ctor-instantiation-with-param car.description = 'Super'; return car; @@ -40,7 +40,7 @@ class MockTires extends Tires { make = 'YokoGoodStone'; } export function testCar() { // #docregion car-ctor-instantiation-with-mocks // Test car with 8 cylinders and YokoGoodStone tires. - let car = new Car(new MockEngine(), new MockTires()); + const car = new Car(new MockEngine(), new MockTires()); // #enddocregion car-ctor-instantiation-with-mocks car.description = 'Test'; return car; diff --git a/aio/content/examples/dependency-injection/src/app/car/car-factory.ts b/aio/content/examples/dependency-injection/src/app/car/car-factory.ts index 06daafe63b..ed759137e6 100644 --- a/aio/content/examples/dependency-injection/src/app/car/car-factory.ts +++ b/aio/content/examples/dependency-injection/src/app/car/car-factory.ts @@ -4,7 +4,7 @@ import { Engine, Tires, Car } from './car'; // BAD pattern! export class CarFactory { createCar() { - let car = new Car(this.createEngine(), this.createTires()); + const car = new Car(this.createEngine(), this.createTires()); car.description = 'Factory'; return car; } diff --git a/aio/content/examples/dependency-injection/src/app/car/car-injector.ts b/aio/content/examples/dependency-injection/src/app/car/car-injector.ts index 000bff7d26..9611bb0073 100644 --- a/aio/content/examples/dependency-injection/src/app/car/car-injector.ts +++ b/aio/content/examples/dependency-injection/src/app/car/car-injector.ts @@ -26,14 +26,14 @@ export function useInjector() { ] }); // #docregion injector-call - let car = injector.get(Car); + const car = injector.get(Car); // #enddocregion injector-call, injector-create-and-call car.description = 'Injector'; injector = Injector.create({ providers: [{ provide: Logger, deps: [] }] }); - let logger = injector.get(Logger); + const logger = injector.get(Logger); logger.log('Injector car.drive() said: ' + car.drive()); return car; } diff --git a/aio/content/examples/dependency-injection/src/app/heroes/hero.service.provider.ts b/aio/content/examples/dependency-injection/src/app/heroes/hero.service.provider.ts index d976e4ed4d..4f86ce4883 100644 --- a/aio/content/examples/dependency-injection/src/app/heroes/hero.service.provider.ts +++ b/aio/content/examples/dependency-injection/src/app/heroes/hero.service.provider.ts @@ -5,7 +5,7 @@ import { Logger } from '../logger.service'; import { UserService } from '../user.service'; // #docregion factory -let heroServiceFactory = (logger: Logger, userService: UserService) => { +const heroServiceFactory = (logger: Logger, userService: UserService) => { return new HeroService(logger, userService.user.isAuthorized); }; // #enddocregion factory diff --git a/aio/content/examples/dependency-injection/src/app/heroes/hero.service.ts b/aio/content/examples/dependency-injection/src/app/heroes/hero.service.ts index 37d70fffca..7d02213153 100644 --- a/aio/content/examples/dependency-injection/src/app/heroes/hero.service.ts +++ b/aio/content/examples/dependency-injection/src/app/heroes/hero.service.ts @@ -17,7 +17,7 @@ export class HeroService { private isAuthorized: boolean) { } getHeroes() { - let auth = this.isAuthorized ? 'authorized ' : 'unauthorized'; + const auth = this.isAuthorized ? 'authorized ' : 'unauthorized'; this.logger.log(`Getting heroes for ${auth} user.`); return HEROES.filter(hero => this.isAuthorized || !hero.isSecret); } diff --git a/aio/content/examples/dependency-injection/src/app/injector.component.ts b/aio/content/examples/dependency-injection/src/app/injector.component.ts index 759607e17b..f04bf022d5 100644 --- a/aio/content/examples/dependency-injection/src/app/injector.component.ts +++ b/aio/content/examples/dependency-injection/src/app/injector.component.ts @@ -36,7 +36,7 @@ export class InjectorComponent implements OnInit { } get rodent() { - let rousDontExist = `R.O.U.S.'s? I don't think they exist!`; + const rousDontExist = `R.O.U.S.'s? I don't think they exist!`; return this.injector.get(ROUS, rousDontExist); } } diff --git a/aio/content/examples/dependency-injection/src/app/providers.component.ts b/aio/content/examples/dependency-injection/src/app/providers.component.ts index e6a98917fb..85c262074a 100644 --- a/aio/content/examples/dependency-injection/src/app/providers.component.ts +++ b/aio/content/examples/dependency-injection/src/app/providers.component.ts @@ -76,7 +76,7 @@ export class EvenBetterLogger extends Logger { constructor(private userService: UserService) { super(); } log(message: string) { - let name = this.userService.user.name; + const name = this.userService.user.name; super.log(`Message to ${name}: ${message}`); } } @@ -237,7 +237,7 @@ export class Provider9Component implements OnInit { import { Optional } from '@angular/core'; // #enddocregion import-optional -let someMessage = 'Hello from the injected logger'; +const someMessage = 'Hello from the injected logger'; @Component({ selector: 'provider-10', diff --git a/aio/content/examples/dependency-injection/src/app/user.service.ts b/aio/content/examples/dependency-injection/src/app/user.service.ts index b665f7c5fa..35de8c92da 100644 --- a/aio/content/examples/dependency-injection/src/app/user.service.ts +++ b/aio/content/examples/dependency-injection/src/app/user.service.ts @@ -8,8 +8,8 @@ export class User { } // TODO: get the user; don't 'new' it. -let alice = new User('Alice', true); -let bob = new User('Bob', false); +const alice = new User('Alice', true); +const bob = new User('Bob', false); @Injectable({ providedIn: 'root' diff --git a/aio/content/examples/displaying-data/e2e/src/app.e2e-spec.ts b/aio/content/examples/displaying-data/e2e/src/app.e2e-spec.ts index e95a657eb0..001708d383 100644 --- a/aio/content/examples/displaying-data/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/displaying-data/e2e/src/app.e2e-spec.ts @@ -1,8 +1,8 @@ import { browser, element, by } from 'protractor'; describe('Displaying Data Tests', () => { - let title = 'Tour of Heroes'; - let defaultHero = 'Windstorm'; + const title = 'Tour of Heroes'; + const defaultHero = 'Windstorm'; beforeAll(() => { browser.get(''); @@ -17,7 +17,7 @@ describe('Displaying Data Tests', () => { }); it('should have heroes', () => { - let heroEls = element.all(by.css('li')); + const heroEls = element.all(by.css('li')); expect(heroEls.count()).not.toBe(0, 'should have heroes'); }); diff --git a/aio/content/examples/docs-style-guide/e2e/src/app.e2e-spec.ts b/aio/content/examples/docs-style-guide/e2e/src/app.e2e-spec.ts index cbcb0c7dbc..c877f9cce9 100644 --- a/aio/content/examples/docs-style-guide/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/docs-style-guide/e2e/src/app.e2e-spec.ts @@ -1,7 +1,7 @@ import { browser, element, by } from 'protractor'; describe('Docs Style Guide', () => { - let title = 'Authors Style Guide Sample'; + const title = 'Authors Style Guide Sample'; beforeAll(() => { browser.get(''); diff --git a/aio/content/examples/dynamic-component-loader/e2e/src/app.e2e-spec.ts b/aio/content/examples/dynamic-component-loader/e2e/src/app.e2e-spec.ts index bf4f615e31..22403372ca 100644 --- a/aio/content/examples/dynamic-component-loader/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/dynamic-component-loader/e2e/src/app.e2e-spec.ts @@ -8,9 +8,9 @@ describe('Dynamic Component Loader', () => { }); it('should load ad banner', () => { - let headline = element(by.xpath("//h4[text()='Featured Hero Profile']")); - let name = element(by.xpath("//h3[text()='Bombasto']")); - let bio = element(by.xpath("//p[text()='Brave as they come']")); + const headline = element(by.xpath("//h4[text()='Featured Hero Profile']")); + const name = element(by.xpath("//h3[text()='Bombasto']")); + const bio = element(by.xpath("//p[text()='Brave as they come']")); expect(name).toBeDefined(); expect(headline).toBeDefined(); diff --git a/aio/content/examples/dynamic-form/e2e/src/app.e2e-spec.ts b/aio/content/examples/dynamic-form/e2e/src/app.e2e-spec.ts index 2c37f69be0..7f01f3100e 100644 --- a/aio/content/examples/dynamic-form/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/dynamic-form/e2e/src/app.e2e-spec.ts @@ -8,17 +8,17 @@ describe('Dynamic Form', () => { }); it('should submit form', () => { - let firstNameElement = element.all(by.css('input[id=firstName]')).get(0); + const firstNameElement = element.all(by.css('input[id=firstName]')).get(0); expect(firstNameElement.getAttribute('value')).toEqual('Bombasto'); - let emailElement = element.all(by.css('input[id=emailAddress]')).get(0); - let email = 'test@test.com'; + const emailElement = element.all(by.css('input[id=emailAddress]')).get(0); + const email = 'test@test.com'; emailElement.sendKeys(email); expect(emailElement.getAttribute('value')).toEqual(email); element(by.css('select option[value="solid"]')).click(); - let saveButton = element.all(by.css('button')).get(0); + const saveButton = element.all(by.css('button')).get(0); saveButton.click().then(() => { expect(element(by.xpath("//strong[contains(text(),'Saved the following values')]")).isPresent()).toBe(true); }); diff --git a/aio/content/examples/dynamic-form/src/app/question-control.service.ts b/aio/content/examples/dynamic-form/src/app/question-control.service.ts index bdfed26136..8c91b2018b 100644 --- a/aio/content/examples/dynamic-form/src/app/question-control.service.ts +++ b/aio/content/examples/dynamic-form/src/app/question-control.service.ts @@ -9,7 +9,7 @@ export class QuestionControlService { constructor() { } toFormGroup(questions: QuestionBase[] ) { - let group: any = {}; + const group: any = {}; questions.forEach(question => { group[question.key] = question.required ? new FormControl(question.value || '', Validators.required) diff --git a/aio/content/examples/dynamic-form/src/app/question.service.ts b/aio/content/examples/dynamic-form/src/app/question.service.ts index e83bf9b769..e5dcf0edbe 100644 --- a/aio/content/examples/dynamic-form/src/app/question.service.ts +++ b/aio/content/examples/dynamic-form/src/app/question.service.ts @@ -12,7 +12,7 @@ export class QuestionService { // TODO: get from a remote source of question metadata getQuestions() { - let questions: QuestionBase[] = [ + const questions: QuestionBase[] = [ new DropdownQuestion({ key: 'brave', diff --git a/aio/content/examples/event-binding/e2e/src/app.e2e-spec.ts b/aio/content/examples/event-binding/e2e/src/app.e2e-spec.ts index 5731d319d1..67b3792ef6 100644 --- a/aio/content/examples/event-binding/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/event-binding/e2e/src/app.e2e-spec.ts @@ -6,12 +6,12 @@ describe('Event binding example', () => { browser.get(''); }); - let saveButton = element.all(by.css('button')).get(0); - let onSaveButton = element.all(by.css('button')).get(1); - let myClick = element.all(by.css('button')).get(2); - let deleteButton = element.all(by.css('button')).get(3); - let saveNoProp = element.all(by.css('button')).get(4); - let saveProp = element.all(by.css('button')).get(5); + const saveButton = element.all(by.css('button')).get(0); + const onSaveButton = element.all(by.css('button')).get(1); + const myClick = element.all(by.css('button')).get(2); + const deleteButton = element.all(by.css('button')).get(3); + const saveNoProp = element.all(by.css('button')).get(4); + const saveProp = element.all(by.css('button')).get(5); it('should display Event Binding with Angular', () => { @@ -28,8 +28,8 @@ describe('Event binding example', () => { }); it('should support user input', () => { - let input = element(by.css('input')); - let bindingResult = element.all(by.css('h4')).get(1); + const input = element(by.css('input')); + const bindingResult = element.all(by.css('h4')).get(1); expect(bindingResult.getText()).toEqual('Result: teapot'); input.sendKeys('abc'); expect(bindingResult.getText()).toEqual('Result: teapotabc'); @@ -42,8 +42,8 @@ describe('Event binding example', () => { }); it('should show two alerts', async () => { - let parentDiv = element.all(by.css('.parent-div')); - let childDiv = element.all(by.css('div > div')).get(1); + const parentDiv = element.all(by.css('.parent-div')); + const childDiv = element.all(by.css('div > div')).get(1); await parentDiv.click(); browser.switchTo().alert().accept(); expect(childDiv.getText()).toEqual('Click me too! (child)'); diff --git a/aio/content/examples/form-validation/e2e/src/app.e2e-spec.ts b/aio/content/examples/form-validation/e2e/src/app.e2e-spec.ts index 599f2b857c..b2590fcfd2 100644 --- a/aio/content/examples/form-validation/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/form-validation/e2e/src/app.e2e-spec.ts @@ -50,8 +50,8 @@ let page: { }; function getPage(sectionTag: string) { - let section = element(by.css(sectionTag)); - let buttons = section.all(by.css('button')); + const section = element(by.css(sectionTag)); + const buttons = section.all(by.css('button')); page = { section, diff --git a/aio/content/examples/forms-overview/src/app/shared/utils.ts b/aio/content/examples/forms-overview/src/app/shared/utils.ts index a7cb3ce69c..37fdaf1659 100644 --- a/aio/content/examples/forms-overview/src/app/shared/utils.ts +++ b/aio/content/examples/forms-overview/src/app/shared/utils.ts @@ -1,5 +1,5 @@ export function createNewEvent(eventName: string, bubbles = false, cancelable = false) { - let evt = document.createEvent('CustomEvent'); + const evt = document.createEvent('CustomEvent'); evt.initCustomEvent(eventName, bubbles, cancelable, null); return evt; } diff --git a/aio/content/examples/forms/e2e/src/app.e2e-spec.ts b/aio/content/examples/forms/e2e/src/app.e2e-spec.ts index 38ed6d899d..5c208c7e41 100644 --- a/aio/content/examples/forms/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/forms/e2e/src/app.e2e-spec.ts @@ -12,49 +12,49 @@ describe('Forms Tests', () => { it('should not display message before submit', () => { - let ele = element(by.css('h2')); + const ele = element(by.css('h2')); expect(ele.isDisplayed()).toBe(false); }); it('should hide form after submit', () => { - let ele = element.all(by.css('h1')).get(0); + const ele = element.all(by.css('h1')).get(0); expect(ele.isDisplayed()).toBe(true); - let b = element.all(by.css('button[type=submit]')).get(0); + const b = element.all(by.css('button[type=submit]')).get(0); b.click().then(() => { expect(ele.isDisplayed()).toBe(false); }); }); it('should display message after submit', () => { - let b = element.all(by.css('button[type=submit]')).get(0); + const b = element.all(by.css('button[type=submit]')).get(0); b.click().then(() => { expect(element(by.css('h2')).getText()).toContain('You submitted the following'); }); }); it('should hide form after submit', () => { - let alterEgoEle = element.all(by.css('input[name=alterEgo]')).get(0); + const alterEgoEle = element.all(by.css('input[name=alterEgo]')).get(0); expect(alterEgoEle.isDisplayed()).toBe(true); - let submitButtonEle = element.all(by.css('button[type=submit]')).get(0); + const submitButtonEle = element.all(by.css('button[type=submit]')).get(0); submitButtonEle.click().then(() => { expect(alterEgoEle.isDisplayed()).toBe(false); }); }); it('should reflect submitted data after submit', () => { - let test = 'testing 1 2 3'; + const test = 'testing 1 2 3'; let newValue: string; - let alterEgoEle = element.all(by.css('input[name=alterEgo]')).get(0); + const alterEgoEle = element.all(by.css('input[name=alterEgo]')).get(0); alterEgoEle.getAttribute('value').then((value: string) => { alterEgoEle.sendKeys(test); newValue = value + test; expect(alterEgoEle.getAttribute('value')).toEqual(newValue); - let b = element.all(by.css('button[type=submit]')).get(0); + const b = element.all(by.css('button[type=submit]')).get(0); return b.click(); }).then(() => { - let alterEgoTextEle = element(by.cssContainingText('div', 'Alter Ego')); + const alterEgoTextEle = element(by.cssContainingText('div', 'Alter Ego')); expect(alterEgoTextEle.isPresent()).toBe(true, 'cannot locate "Alter Ego" label'); - let divEle = element(by.cssContainingText('div', newValue)); + const divEle = element(by.cssContainingText('div', newValue)); expect(divEle.isPresent()).toBe(true, 'cannot locate div with this text: ' + newValue); }); }); diff --git a/aio/content/examples/forms/src/app/hero-form/hero-form.component.ts b/aio/content/examples/forms/src/app/hero-form/hero-form.component.ts index d855dffa5f..c155206786 100644 --- a/aio/content/examples/forms/src/app/hero-form/hero-form.component.ts +++ b/aio/content/examples/forms/src/app/hero-form/hero-form.component.ts @@ -35,7 +35,7 @@ export class HeroFormComponent { skyDog(): Hero { // #docregion SkyDog - let myHero = new Hero(42, 'SkyDog', + const myHero = new Hero(42, 'SkyDog', 'Fetch any object at any distance', 'Leslie Rollover'); console.log('My hero is called ' + myHero.name); // "My hero is called SkyDog" diff --git a/aio/content/examples/hierarchical-dependency-injection/e2e/src/app.e2e-spec.ts b/aio/content/examples/hierarchical-dependency-injection/e2e/src/app.e2e-spec.ts index 138f2fe9e0..277b2cc414 100644 --- a/aio/content/examples/hierarchical-dependency-injection/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/hierarchical-dependency-injection/e2e/src/app.e2e-spec.ts @@ -7,7 +7,7 @@ describe('Hierarchical dependency injection', () => { }); describe('Heroes Scenario', () => { - let page = { + const page = { heroName: '', income: '', diff --git a/aio/content/examples/http/e2e/src/app.e2e-spec.ts b/aio/content/examples/http/e2e/src/app.e2e-spec.ts index c181fe163e..b74d2ea951 100644 --- a/aio/content/examples/http/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/http/e2e/src/app.e2e-spec.ts @@ -24,7 +24,7 @@ const page = { uploadMessage: element(by.css('app-uploader p')) }; -let checkLogForMessage = (message: string) => { +const checkLogForMessage = (message: string) => { expect(page.logList.getText()).toContain(message); }; diff --git a/aio/content/examples/http/src/testing/http-client.spec.ts b/aio/content/examples/http/src/testing/http-client.spec.ts index 047f29b4fe..abbb1115d8 100644 --- a/aio/content/examples/http/src/testing/http-client.spec.ts +++ b/aio/content/examples/http/src/testing/http-client.spec.ts @@ -90,7 +90,7 @@ describe('HttpClient testing', () => { }); it('can test multiple requests', () => { - let testData: Data[] = [ + const testData: Data[] = [ { name: 'bob' }, { name: 'carol' }, { name: 'ted' }, { name: 'alice' } ]; diff --git a/aio/content/examples/inputs-outputs/e2e/src/app.e2e-spec.ts b/aio/content/examples/inputs-outputs/e2e/src/app.e2e-spec.ts index 145e42bab7..9fa48c7eb5 100644 --- a/aio/content/examples/inputs-outputs/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/inputs-outputs/e2e/src/app.e2e-spec.ts @@ -18,43 +18,43 @@ describe('Inputs and Outputs', () => { } it('should have title Inputs and Outputs', () => { - let title = element.all(by.css('h1')).get(0); + const title = element.all(by.css('h1')).get(0); expect(title.getText()).toEqual('Inputs and Outputs'); }); it('should add 123 to the parent list', async () => { - let addToParentButton = element.all(by.css('button')).get(0); - let addToListInput = element.all(by.css('input')).get(0); - let addedItem = element.all(by.css('li')).get(4); + const addToParentButton = element.all(by.css('button')).get(0); + const addToListInput = element.all(by.css('input')).get(0); + const addedItem = element.all(by.css('li')).get(4); await addToListInput.sendKeys('123'); await addToParentButton.click(); expect(addedItem.getText()).toEqual('123'); }); it('should delete item', async () => { - let deleteButton = element.all(by.css('button')).get(1); + const deleteButton = element.all(by.css('button')).get(1); const contents = 'Child'; await deleteButton.click(); await logChecker(deleteButton, contents); }); it('should log buy the item', async () => { - let buyButton = element.all(by.css('button')).get(2); + const buyButton = element.all(by.css('button')).get(2); const contents = 'Child'; await buyButton.click(); await logChecker(buyButton, contents); }); it('should save item for later', async () => { - let saveButton = element.all(by.css('button')).get(3); + const saveButton = element.all(by.css('button')).get(3); const contents = 'Child'; await saveButton.click(); await logChecker(saveButton, contents); }); it('should add item to wishlist', async () => { - let addToParentButton = element.all(by.css('button')).get(4); - let addedItem = element.all(by.css('li')).get(6); + const addToParentButton = element.all(by.css('button')).get(4); + const addedItem = element.all(by.css('li')).get(6); await addToParentButton.click(); expect(addedItem.getText()).toEqual('Television'); }); diff --git a/aio/content/examples/interpolation/e2e/src/app.e2e-spec.ts b/aio/content/examples/interpolation/e2e/src/app.e2e-spec.ts index f1de8f89d1..63e713bd98 100644 --- a/aio/content/examples/interpolation/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/interpolation/e2e/src/app.e2e-spec.ts @@ -27,8 +27,8 @@ describe('Interpolation e2e tests', () => { }); it('should display two pictures', () => { - let pottedPlant = element.all(by.css('img')).get(0); - let lamp = element.all(by.css('img')).get(1); + const pottedPlant = element.all(by.css('img')).get(0); + const lamp = element.all(by.css('img')).get(1); expect(pottedPlant.getAttribute('src')).toContain('potted-plant'); expect(pottedPlant.isDisplayed()).toBe(true); @@ -38,8 +38,8 @@ describe('Interpolation e2e tests', () => { }); it('should support user input', () => { - let input = element(by.css('input')); - let label = element(by.css('label')); + const input = element(by.css('input')); + const label = element(by.css('label')); expect(label.getText()).toEqual('Type something:'); input.sendKeys('abc'); expect(label.getText()).toEqual('Type something: abc'); diff --git a/aio/content/examples/lazy-loading-ngmodules/e2e/src/app.e2e-spec.ts b/aio/content/examples/lazy-loading-ngmodules/e2e/src/app.e2e-spec.ts index fb8b4b2661..744abfa7ef 100644 --- a/aio/content/examples/lazy-loading-ngmodules/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/lazy-loading-ngmodules/e2e/src/app.e2e-spec.ts @@ -24,7 +24,7 @@ describe('providers App', () => { }); it('should show customers when the button is clicked', () => { - let customersMessage = element(by.css('app-customers > p')); + const customersMessage = element(by.css('app-customers > p')); expect(customersMessage.getText()).toBe('customers works!'); }); @@ -36,7 +36,7 @@ describe('providers App', () => { }); it('should show orders when the button is clicked', () => { - let ordersMessage = element(by.css('app-orders > p')); + const ordersMessage = element(by.css('app-orders > p')); expect(ordersMessage.getText()).toBe('orders works!'); }); diff --git a/aio/content/examples/lifecycle-hooks/e2e/src/app.e2e-spec.ts b/aio/content/examples/lifecycle-hooks/e2e/src/app.e2e-spec.ts index 286a41c2fe..8aa8ee9f29 100644 --- a/aio/content/examples/lifecycle-hooks/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/lifecycle-hooks/e2e/src/app.e2e-spec.ts @@ -13,11 +13,11 @@ describe('Lifecycle hooks', () => { }); it('should support peek-a-boo', async () => { - let pabComp = element(by.css('peek-a-boo-parent peek-a-boo')); + const pabComp = element(by.css('peek-a-boo-parent peek-a-boo')); expect(pabComp.isPresent()).toBe(false, 'should not be able to find the "peek-a-boo" component'); - let pabButton = element.all(by.css('peek-a-boo-parent button')).get(0); - let updateHeroButton = element.all(by.css('peek-a-boo-parent button')).get(1); + const pabButton = element.all(by.css('peek-a-boo-parent button')).get(0); + const updateHeroButton = element.all(by.css('peek-a-boo-parent button')).get(1); expect(pabButton.getText()).toContain('Create Peek'); await pabButton.click(); @@ -35,12 +35,12 @@ describe('Lifecycle hooks', () => { }); it('should support OnChanges hook', () => { - let onChangesViewEle = element.all(by.css('on-changes div')).get(0); - let inputEles = element.all(by.css('on-changes-parent input')); - let heroNameInputEle = inputEles.get(1); - let powerInputEle = inputEles.get(0); - let titleEle = onChangesViewEle.element(by.css('p')); - let changeLogEles = onChangesViewEle.all(by.css('div')); + const onChangesViewEle = element.all(by.css('on-changes div')).get(0); + const inputEles = element.all(by.css('on-changes-parent input')); + const heroNameInputEle = inputEles.get(1); + const powerInputEle = inputEles.get(0); + const titleEle = onChangesViewEle.element(by.css('p')); + const changeLogEles = onChangesViewEle.all(by.css('div')); expect(titleEle.getText()).toContain('Windstorm can sing'); expect(changeLogEles.count()).toEqual(2, 'should start with 2 messages'); @@ -54,12 +54,12 @@ describe('Lifecycle hooks', () => { }); it('should support DoCheck hook', async () => { - let doCheckViewEle = element.all(by.css('do-check div')).get(0); - let inputEles = element.all(by.css('do-check-parent input')); - let heroNameInputEle = inputEles.get(1); - let powerInputEle = inputEles.get(0); - let titleEle = doCheckViewEle.element(by.css('p')); - let changeLogEles = doCheckViewEle.all(by.css('div')); + const doCheckViewEle = element.all(by.css('do-check div')).get(0); + const inputEles = element.all(by.css('do-check-parent input')); + const heroNameInputEle = inputEles.get(1); + const powerInputEle = inputEles.get(0); + const titleEle = doCheckViewEle.element(by.css('p')); + const changeLogEles = doCheckViewEle.all(by.css('div')); let logCount: number; expect(titleEle.getText()).toContain('Windstorm can sing'); @@ -82,11 +82,11 @@ describe('Lifecycle hooks', () => { }); it('should support AfterView hooks', async () => { - let parentEle = element(by.tagName('after-view-parent')); - let buttonEle = parentEle.element(by.tagName('button')); // Reset - let commentEle = parentEle.element(by.className('comment')); - let logEles = parentEle.all(by.css('h4 ~ div')); - let childViewInputEle = parentEle.element(by.css('app-child-view input')); + const parentEle = element(by.tagName('after-view-parent')); + const buttonEle = parentEle.element(by.tagName('button')); // Reset + const commentEle = parentEle.element(by.className('comment')); + const logEles = parentEle.all(by.css('h4 ~ div')); + const childViewInputEle = parentEle.element(by.css('app-child-view input')); let logCount: number; expect(childViewInputEle.getAttribute('value')).toContain('Magneta'); @@ -99,7 +99,7 @@ describe('Lifecycle hooks', () => { expect(commentEle.isPresent()).toBe(true, 'should have comment because >10 chars'); expect(commentEle.getText()).toContain('long name'); - let count = await logEles.count(); + const count = await logEles.count(); expect(logCount + 7).toBeGreaterThan(count - 3, '7 additional log messages should have been added'); expect(logCount + 7).toBeLessThan(count + 3, '7 additional log messages should have been added'); @@ -109,18 +109,18 @@ describe('Lifecycle hooks', () => { }); it('should support AfterContent hooks', async () => { - let parentEle = element(by.tagName('after-content-parent')); - let buttonEle = parentEle.element(by.tagName('button')); // Reset - let commentEle = parentEle.element(by.className('comment')); - let logEles = parentEle.all(by.css('h4 ~ div')); - let childViewInputEle = parentEle.element(by.css('app-child input')); + const parentEle = element(by.tagName('after-content-parent')); + const buttonEle = parentEle.element(by.tagName('button')); // Reset + const commentEle = parentEle.element(by.className('comment')); + const logEles = parentEle.all(by.css('h4 ~ div')); + const childViewInputEle = parentEle.element(by.css('app-child input')); let logCount = await logEles.count(); expect(childViewInputEle.getAttribute('value')).toContain('Magneta'); expect(commentEle.isPresent()).toBe(false, 'comment should not be in DOM'); await sendKeys(childViewInputEle, '-test-'); - let count = await logEles.count(); + const count = await logEles.count(); expect(childViewInputEle.getAttribute('value')).toContain('-test-'); expect(commentEle.isPresent()).toBe(true, 'should have comment because >10 chars'); expect(commentEle.getText()).toContain('long name'); @@ -132,11 +132,11 @@ describe('Lifecycle hooks', () => { }); it('should support spy\'s OnInit & OnDestroy hooks', async () => { - let inputEle = element(by.css('spy-parent input')); - let addHeroButtonEle = element(by.cssContainingText('spy-parent button', 'Add Hero')); - let resetHeroesButtonEle = element(by.cssContainingText('spy-parent button', 'Reset Heroes')); - let heroEles = element.all(by.css('spy-parent div[mySpy')); - let logEles = element.all(by.css('spy-parent h4 ~ div')); + const inputEle = element(by.css('spy-parent input')); + const addHeroButtonEle = element(by.cssContainingText('spy-parent button', 'Add Hero')); + const resetHeroesButtonEle = element(by.cssContainingText('spy-parent button', 'Reset Heroes')); + const heroEles = element.all(by.css('spy-parent div[mySpy')); + const logEles = element.all(by.css('spy-parent h4 ~ div')); expect(heroEles.count()).toBe(2, 'should have two heroes displayed'); expect(logEles.count()).toBe(2, 'should have two log entries'); @@ -153,10 +153,10 @@ describe('Lifecycle hooks', () => { }); it('should support "spy counter"', async () => { - let updateCounterButtonEle = element(by.cssContainingText('counter-parent button', 'Update')); - let resetCounterButtonEle = element(by.cssContainingText('counter-parent button', 'Reset')); - let textEle = element(by.css('counter-parent app-counter > div')); - let logEles = element.all(by.css('counter-parent h4 ~ div')); + const updateCounterButtonEle = element(by.cssContainingText('counter-parent button', 'Update')); + const resetCounterButtonEle = element(by.cssContainingText('counter-parent button', 'Reset')); + const textEle = element(by.css('counter-parent app-counter > div')); + const logEles = element.all(by.css('counter-parent h4 ~ div')); expect(textEle.getText()).toContain('Counter = 0'); expect(logEles.count()).toBe(2, 'should start with two log entries'); diff --git a/aio/content/examples/lifecycle-hooks/src/app/after-content.component.ts b/aio/content/examples/lifecycle-hooks/src/app/after-content.component.ts index 84ab4154ff..1de8a84612 100644 --- a/aio/content/examples/lifecycle-hooks/src/app/after-content.component.ts +++ b/aio/content/examples/lifecycle-hooks/src/app/after-content.component.ts @@ -67,8 +67,8 @@ export class AfterContentComponent implements AfterContentChecked, AfterContentI } private logIt(method: string) { - let child = this.contentChild; - let message = `${method}: ${child ? child.hero : 'no'} child content`; + const child = this.contentChild; + const message = `${method}: ${child ? child.hero : 'no'} child content`; this.logger.log(message); } // #docregion hooks diff --git a/aio/content/examples/lifecycle-hooks/src/app/after-view.component.ts b/aio/content/examples/lifecycle-hooks/src/app/after-view.component.ts index 9d84dada73..534d0b4090 100644 --- a/aio/content/examples/lifecycle-hooks/src/app/after-view.component.ts +++ b/aio/content/examples/lifecycle-hooks/src/app/after-view.component.ts @@ -67,7 +67,7 @@ export class AfterViewComponent implements AfterViewChecked, AfterViewInit { // #docregion do-something // This surrogate for real business logic sets the `comment` private doSomething() { - let c = this.viewChild.hero.length > 10 ? `That's a long name` : ''; + const c = this.viewChild.hero.length > 10 ? `That's a long name` : ''; if (c !== this.comment) { // Wait a tick because the component's view has already been checked this.logger.tick_then(() => this.comment = c); @@ -76,8 +76,8 @@ export class AfterViewComponent implements AfterViewChecked, AfterViewInit { // #enddocregion do-something private logIt(method: string) { - let child = this.viewChild; - let message = `${method}: ${child ? child.hero : 'no'} child view`; + const child = this.viewChild; + const message = `${method}: ${child ? child.hero : 'no'} child view`; this.logger.log(message); } // #docregion hooks diff --git a/aio/content/examples/lifecycle-hooks/src/app/counter.component.ts b/aio/content/examples/lifecycle-hooks/src/app/counter.component.ts index f2f3bcfb2b..cddc847136 100644 --- a/aio/content/examples/lifecycle-hooks/src/app/counter.component.ts +++ b/aio/content/examples/lifecycle-hooks/src/app/counter.component.ts @@ -31,9 +31,9 @@ export class MyCounterComponent implements OnChanges { } // A change to `counter` is the only change we care about - let chng = changes.counter; - let cur = chng.currentValue; - let prev = JSON.stringify(chng.previousValue); // first time is {}; after is integer + const chng = changes.counter; + const cur = chng.currentValue; + const prev = JSON.stringify(chng.previousValue); // first time is {}; after is integer this.changeLog.push(`counter: currentValue = ${cur}, previousValue = ${prev}`); } } diff --git a/aio/content/examples/lifecycle-hooks/src/app/do-check.component.ts b/aio/content/examples/lifecycle-hooks/src/app/do-check.component.ts index 4b8a088b9a..82a830dd98 100644 --- a/aio/content/examples/lifecycle-hooks/src/app/do-check.component.ts +++ b/aio/content/examples/lifecycle-hooks/src/app/do-check.component.ts @@ -51,8 +51,8 @@ export class DoCheckComponent implements DoCheck { this.noChangeCount = 0; } else { // log that hook was called when there was no relevant change. - let count = this.noChangeCount += 1; - let noChangeMsg = `DoCheck called ${count}x when no change to hero or power`; + const count = this.noChangeCount += 1; + const noChangeMsg = `DoCheck called ${count}x when no change to hero or power`; if (count === 1) { // add new "no change" message this.changeLog.push(noChangeMsg); diff --git a/aio/content/examples/lifecycle-hooks/src/app/on-changes.component.ts b/aio/content/examples/lifecycle-hooks/src/app/on-changes.component.ts index 7b9cda05ef..b6b8ba2f9e 100644 --- a/aio/content/examples/lifecycle-hooks/src/app/on-changes.component.ts +++ b/aio/content/examples/lifecycle-hooks/src/app/on-changes.component.ts @@ -34,10 +34,10 @@ export class OnChangesComponent implements OnChanges { // #docregion ng-on-changes ngOnChanges(changes: SimpleChanges) { - for (let propName in changes) { - let chng = changes[propName]; - let cur = JSON.stringify(chng.currentValue); - let prev = JSON.stringify(chng.previousValue); + for (const propName in changes) { + const chng = changes[propName]; + const cur = JSON.stringify(chng.currentValue); + const prev = JSON.stringify(chng.previousValue); this.changeLog.push(`${propName}: currentValue = ${cur}, previousValue = ${prev}`); } } diff --git a/aio/content/examples/lifecycle-hooks/src/app/peek-a-boo.component.ts b/aio/content/examples/lifecycle-hooks/src/app/peek-a-boo.component.ts index 30252929e4..a597a5ca73 100644 --- a/aio/content/examples/lifecycle-hooks/src/app/peek-a-boo.component.ts +++ b/aio/content/examples/lifecycle-hooks/src/app/peek-a-boo.component.ts @@ -48,16 +48,16 @@ export class PeekABooComponent extends PeekABooDirective implements constructor(logger: LoggerService) { super(logger); - let is = this.name ? 'is' : 'is not'; + const is = this.name ? 'is' : 'is not'; this.logIt(`name ${is} known at construction`); } // only called for/if there is an @input variable set by parent. ngOnChanges(changes: SimpleChanges) { - let changesMsgs: string[] = []; - for (let propName in changes) { + const changesMsgs: string[] = []; + for (const propName in changes) { if (propName === 'name') { - let name = changes.name.currentValue; + const name = changes.name.currentValue; changesMsgs.push(`name ${this.verb} to "${name}"`); } else { changesMsgs.push(propName + ' ' + this.verb); diff --git a/aio/content/examples/ngmodules/src/app/contact/contact.component.ts b/aio/content/examples/ngmodules/src/app/contact/contact.component.ts index 5af8c628fe..9cea3c8829 100644 --- a/aio/content/examples/ngmodules/src/app/contact/contact.component.ts +++ b/aio/content/examples/ngmodules/src/app/contact/contact.component.ts @@ -46,7 +46,7 @@ export class ContactComponent implements OnInit { } onSubmit() { - let newName = this.contactForm.get('name').value; + const newName = this.contactForm.get('name').value; this.displayMessage('Saved ' + newName); this.contact.name = newName; } diff --git a/aio/content/examples/ngmodules/src/app/customers/customers-detail.component.ts b/aio/content/examples/ngmodules/src/app/customers/customers-detail.component.ts index 5e2d71677c..7d0818f242 100644 --- a/aio/content/examples/ngmodules/src/app/customers/customers-detail.component.ts +++ b/aio/content/examples/ngmodules/src/app/customers/customers-detail.component.ts @@ -25,7 +25,7 @@ export class CustomersDetailComponent implements OnInit { private customersService: CustomersService) { } ngOnInit() { - let id = parseInt(this.route.snapshot.paramMap.get('id'), 10); + const id = parseInt(this.route.snapshot.paramMap.get('id'), 10); this.customersService.getCustomer(id).subscribe(customer => this.customer = customer); } } diff --git a/aio/content/examples/pipes/e2e/src/app.e2e-spec.ts b/aio/content/examples/pipes/e2e/src/app.e2e-spec.ts index 478c2ca905..e4ef900a6c 100644 --- a/aio/content/examples/pipes/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/pipes/e2e/src/app.e2e-spec.ts @@ -26,13 +26,13 @@ describe('Pipes', () => { }); it('should be able to toggle birthday formats', () => { - let birthDayEle = element(by.css('app-hero-birthday2 > p')); + const birthDayEle = element(by.css('app-hero-birthday2 > p')); if (angularVersion.indexOf('4.') === 0) { // Breaking change between v4 and v5 (https://github.com/angular/angular/commit/079d884) expect(birthDayEle.getText()).toEqual(`The hero's birthday is 4/15/1988`); } else { expect(birthDayEle.getText()).toEqual(`The hero's birthday is 4/15/88`); } - let buttonEle = element(by.cssContainingText('app-hero-birthday2 > button', 'Toggle Format')); + const buttonEle = element(by.cssContainingText('app-hero-birthday2 > button', 'Toggle Format')); expect(buttonEle.isDisplayed()).toBe(true); buttonEle.click().then(() => { expect(birthDayEle.getText()).toEqual(`The hero's birthday is Friday, April 15, 1988`); @@ -40,7 +40,7 @@ describe('Pipes', () => { }); it('should be able to chain and compose pipes', () => { - let chainedPipeEles = element.all(by.cssContainingText('app-root p', `The chained hero's`)); + const chainedPipeEles = element.all(by.cssContainingText('app-root p', `The chained hero's`)); expect(chainedPipeEles.count()).toBe(3, 'should have 3 chained pipe examples'); expect(chainedPipeEles.get(0).getText()).toContain('APR 15, 1988'); expect(chainedPipeEles.get(1).getText()).toContain('FRIDAY, APRIL 15, 1988'); @@ -48,15 +48,15 @@ describe('Pipes', () => { }); it('should be able to use ExponentialStrengthPipe pipe', () => { - let ele = element(by.css('app-power-booster p')); + const ele = element(by.css('app-power-booster p')); expect(ele.getText()).toContain('Super power boost: 1024'); }); it('should be able to use the exponential calculator', () => { - let eles = element.all(by.css('app-power-boost-calculator input')); - let baseInputEle = eles.get(0); - let factorInputEle = eles.get(1); - let outputEle = element(by.css('app-power-boost-calculator p')); + const eles = element.all(by.css('app-power-boost-calculator input')); + const baseInputEle = eles.get(0); + const factorInputEle = eles.get(1); + const outputEle = element(by.css('app-power-boost-calculator p')); baseInputEle.clear().then(() => { baseInputEle.sendKeys('7'); return factorInputEle.clear(); @@ -68,11 +68,11 @@ describe('Pipes', () => { it('should support flying heroes (pure) ', () => { - let nameEle = element(by.css('app-flying-heroes input[type="text"]')); - let canFlyCheckEle = element(by.css('app-flying-heroes #can-fly')); - let mutateCheckEle = element(by.css('app-flying-heroes #mutate')); - let resetEle = element(by.css('app-flying-heroes button')); - let flyingHeroesEle = element.all(by.css('app-flying-heroes #flyers div')); + const nameEle = element(by.css('app-flying-heroes input[type="text"]')); + const canFlyCheckEle = element(by.css('app-flying-heroes #can-fly')); + const mutateCheckEle = element(by.css('app-flying-heroes #mutate')); + const resetEle = element(by.css('app-flying-heroes button')); + const flyingHeroesEle = element.all(by.css('app-flying-heroes #flyers div')); expect(canFlyCheckEle.getAttribute('checked')).toEqual('true', 'should default to "can fly"'); expect(mutateCheckEle.getAttribute('checked')).toEqual('true', 'should default to mutating array'); @@ -94,10 +94,10 @@ describe('Pipes', () => { it('should support flying heroes (impure) ', () => { - let nameEle = element(by.css('app-flying-heroes-impure input[type="text"]')); - let canFlyCheckEle = element(by.css('app-flying-heroes-impure #can-fly')); - let mutateCheckEle = element(by.css('app-flying-heroes-impure #mutate')); - let flyingHeroesEle = element.all(by.css('app-flying-heroes-impure #flyers div')); + const nameEle = element(by.css('app-flying-heroes-impure input[type="text"]')); + const canFlyCheckEle = element(by.css('app-flying-heroes-impure #can-fly')); + const mutateCheckEle = element(by.css('app-flying-heroes-impure #mutate')); + const flyingHeroesEle = element.all(by.css('app-flying-heroes-impure #flyers div')); expect(canFlyCheckEle.getAttribute('checked')).toEqual('true', 'should default to "can fly"'); expect(mutateCheckEle.getAttribute('checked')).toEqual('true', 'should default to mutating array'); diff --git a/aio/content/examples/pipes/src/app/flying-heroes.component.ts b/aio/content/examples/pipes/src/app/flying-heroes.component.ts index 179b8296e9..526f3b2842 100644 --- a/aio/content/examples/pipes/src/app/flying-heroes.component.ts +++ b/aio/content/examples/pipes/src/app/flying-heroes.component.ts @@ -23,7 +23,7 @@ export class FlyingHeroesComponent { addHero(name: string) { name = name.trim(); if (!name) { return; } - let hero = {name, canFly: this.canFly}; + const hero = {name, canFly: this.canFly}; // #enddocregion v1 if (this.mutate) { // Pure pipe won't update display because heroes array reference is unchanged diff --git a/aio/content/examples/router/e2e/src/app.e2e-spec.ts b/aio/content/examples/router/e2e/src/app.e2e-spec.ts index 2d7e2fc22e..00d3bad6de 100644 --- a/aio/content/examples/router/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/router/e2e/src/app.e2e-spec.ts @@ -100,7 +100,7 @@ describe('Router', () => { await page.heroesHref.click(); await browser.sleep(600); const heroEle = page.heroesList.get(4); - let text = await heroEle.getText(); + const text = await heroEle.getText(); expect(text.length).toBeGreaterThan(0, 'hero item text length'); // remove leading id from text const heroText = text.substr(text.indexOf(' ')).trim(); @@ -110,11 +110,11 @@ describe('Router', () => { expect(page.heroesList.count()).toBe(0, 'hero list count'); expect(page.heroDetail.isPresent()).toBe(true, 'hero detail'); expect(page.heroDetailTitle.getText()).toContain(heroText); - let inputEle = page.heroDetail.element(by.css('input')); + const inputEle = page.heroDetail.element(by.css('input')); await inputEle.sendKeys('-foo'); expect(page.heroDetailTitle.getText()).toContain(heroText + '-foo'); - let buttonEle = page.heroDetail.element(by.css('button')); + const buttonEle = page.heroDetail.element(by.css('button')); await buttonEle.click(); await browser.sleep(600); expect(heroEle.getText()).toContain(heroText + '-foo'); @@ -166,7 +166,7 @@ describe('Router', () => { const page = getPageStruct(); await page.crisisHref.click(); let crisisEle = page.crisisList.get(index); - let text = await crisisEle.getText(); + const text = await crisisEle.getText(); expect(text.length).toBeGreaterThan(0, 'crisis item text length'); // remove leading id from text const crisisText = text.substr(text.indexOf(' ')).trim(); @@ -174,10 +174,10 @@ describe('Router', () => { await crisisEle.click(); expect(page.crisisDetail.isPresent()).toBe(true, 'crisis detail present'); expect(page.crisisDetailTitle.getText()).toContain(crisisText); - let inputEle = page.crisisDetail.element(by.css('input')); + const inputEle = page.crisisDetail.element(by.css('input')); await inputEle.sendKeys('-foo'); - let buttonEle = page.crisisDetail.element(by.buttonText(save ? 'Save' : 'Cancel')); + const buttonEle = page.crisisDetail.element(by.buttonText(save ? 'Save' : 'Cancel')); await buttonEle.click(); crisisEle = page.crisisList.get(index); if (save) { diff --git a/aio/content/examples/router/src/app/auth/auth.guard.2.ts b/aio/content/examples/router/src/app/auth/auth.guard.2.ts index f34bd21204..80df7d7032 100644 --- a/aio/content/examples/router/src/app/auth/auth.guard.2.ts +++ b/aio/content/examples/router/src/app/auth/auth.guard.2.ts @@ -13,7 +13,7 @@ export class AuthGuard implements CanActivate { canActivate( next: ActivatedRouteSnapshot, state: RouterStateSnapshot): true|UrlTree { - let url: string = state.url; + const url: string = state.url; return this.checkLogin(url); } diff --git a/aio/content/examples/router/src/app/auth/auth.guard.3.ts b/aio/content/examples/router/src/app/auth/auth.guard.3.ts index e4500e0759..5125795eb8 100644 --- a/aio/content/examples/router/src/app/auth/auth.guard.3.ts +++ b/aio/content/examples/router/src/app/auth/auth.guard.3.ts @@ -18,7 +18,7 @@ export class AuthGuard implements CanActivate, CanActivateChild { canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot): true|UrlTree { - let url: string = state.url; + const url: string = state.url; return this.checkLogin(url); } diff --git a/aio/content/examples/router/src/app/auth/auth.guard.4.ts b/aio/content/examples/router/src/app/auth/auth.guard.4.ts index 4d3f0f0280..bc4be84e46 100644 --- a/aio/content/examples/router/src/app/auth/auth.guard.4.ts +++ b/aio/content/examples/router/src/app/auth/auth.guard.4.ts @@ -18,7 +18,7 @@ export class AuthGuard implements CanActivate, CanActivateChild { constructor(private authService: AuthService, private router: Router) {} canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): true|UrlTree { - let url: string = state.url; + const url: string = state.url; return this.checkLogin(url); } @@ -34,11 +34,11 @@ export class AuthGuard implements CanActivate, CanActivateChild { this.authService.redirectUrl = url; // Create a dummy session id - let sessionId = 123456789; + const sessionId = 123456789; // Set our navigation extras object // that contains our global query params and fragment - let navigationExtras: NavigationExtras = { + const navigationExtras: NavigationExtras = { queryParams: { session_id: sessionId }, fragment: 'anchor' }; diff --git a/aio/content/examples/router/src/app/auth/auth.guard.ts b/aio/content/examples/router/src/app/auth/auth.guard.ts index ef19d6165a..3aa5487708 100644 --- a/aio/content/examples/router/src/app/auth/auth.guard.ts +++ b/aio/content/examples/router/src/app/auth/auth.guard.ts @@ -17,7 +17,7 @@ export class AuthGuard implements CanActivate, CanActivateChild, CanLoad { constructor(private authService: AuthService, private router: Router) {} canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { - let url: string = state.url; + const url: string = state.url; return this.checkLogin(url); } @@ -28,7 +28,7 @@ export class AuthGuard implements CanActivate, CanActivateChild, CanLoad { // #docregion, canLoad canLoad(route: Route): boolean { - let url = `/${route.path}`; + const url = `/${route.path}`; return this.checkLogin(url); } @@ -41,11 +41,11 @@ export class AuthGuard implements CanActivate, CanActivateChild, CanLoad { this.authService.redirectUrl = url; // Create a dummy session id - let sessionId = 123456789; + const sessionId = 123456789; // Set our navigation extras object // that contains our global query params and fragment - let navigationExtras: NavigationExtras = { + const navigationExtras: NavigationExtras = { queryParams: { session_id: sessionId }, fragment: 'anchor' }; diff --git a/aio/content/examples/router/src/app/auth/login/login.component.ts b/aio/content/examples/router/src/app/auth/login/login.component.ts index 652afc66f3..66461effca 100644 --- a/aio/content/examples/router/src/app/auth/login/login.component.ts +++ b/aio/content/examples/router/src/app/auth/login/login.component.ts @@ -32,7 +32,7 @@ export class LoginComponent { // #docregion preserve // Set our navigation extras object // that passes on our global query params and fragment - let navigationExtras: NavigationExtras = { + const navigationExtras: NavigationExtras = { queryParamsHandling: 'preserve', preserveFragment: true }; diff --git a/aio/content/examples/router/src/app/crisis-center/crisis-detail-resolver.service.ts b/aio/content/examples/router/src/app/crisis-center/crisis-detail-resolver.service.ts index bd9b468bf0..cc521b439a 100644 --- a/aio/content/examples/router/src/app/crisis-center/crisis-detail-resolver.service.ts +++ b/aio/content/examples/router/src/app/crisis-center/crisis-detail-resolver.service.ts @@ -19,7 +19,7 @@ export class CrisisDetailResolverService implements Resolve { constructor(private cs: CrisisService, private router: Router) {} resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Observable { - let id = route.paramMap.get('id'); + const id = route.paramMap.get('id'); return this.cs.getCrisis(id).pipe( take(1), diff --git a/aio/content/examples/router/src/app/crisis-center/crisis-detail/crisis-detail.component.1.ts b/aio/content/examples/router/src/app/crisis-center/crisis-detail/crisis-detail.component.1.ts index 18bb53e2ca..6b1399eb9a 100644 --- a/aio/content/examples/router/src/app/crisis-center/crisis-detail/crisis-detail.component.1.ts +++ b/aio/content/examples/router/src/app/crisis-center/crisis-detail/crisis-detail.component.1.ts @@ -62,7 +62,7 @@ export class CrisisDetailComponent implements OnInit { } gotoCrises() { - let crisisId = this.crisis ? this.crisis.id : null; + const crisisId = this.crisis ? this.crisis.id : null; // Pass along the crisis id if available // so that the CrisisListComponent can select that crisis. // Add a totally useless `foo` parameter for kicks. diff --git a/aio/content/examples/router/src/app/crisis-center/crisis-detail/crisis-detail.component.ts b/aio/content/examples/router/src/app/crisis-center/crisis-detail/crisis-detail.component.ts index 7e3d9b059e..3ce296d04c 100644 --- a/aio/content/examples/router/src/app/crisis-center/crisis-detail/crisis-detail.component.ts +++ b/aio/content/examples/router/src/app/crisis-center/crisis-detail/crisis-detail.component.ts @@ -56,7 +56,7 @@ export class CrisisDetailComponent implements OnInit { // #enddocregion canDeactivate gotoCrises() { - let crisisId = this.crisis ? this.crisis.id : null; + const crisisId = this.crisis ? this.crisis.id : null; // Pass along the crisis id if available // so that the CrisisListComponent can select that crisis. // Add a totally useless `foo` parameter for kicks. diff --git a/aio/content/examples/router/src/app/crisis-center/crisis.service.ts b/aio/content/examples/router/src/app/crisis-center/crisis.service.ts index a1ebc42256..957b65c9c9 100644 --- a/aio/content/examples/router/src/app/crisis-center/crisis.service.ts +++ b/aio/content/examples/router/src/app/crisis-center/crisis.service.ts @@ -29,7 +29,7 @@ export class CrisisService { addCrisis(name: string) { name = name.trim(); if (name) { - let crisis = { id: CrisisService.nextCrisisId++, name }; + const crisis = { id: CrisisService.nextCrisisId++, name }; CRISES.push(crisis); this.crises$.next(CRISES); } diff --git a/aio/content/examples/router/src/app/heroes/hero-detail/hero-detail.component.2.ts b/aio/content/examples/router/src/app/heroes/hero-detail/hero-detail.component.2.ts index 6652848546..135863ebff 100644 --- a/aio/content/examples/router/src/app/heroes/hero-detail/hero-detail.component.2.ts +++ b/aio/content/examples/router/src/app/heroes/hero-detail/hero-detail.component.2.ts @@ -23,7 +23,7 @@ export class HeroDetailComponent implements OnInit { // #docregion snapshot ngOnInit() { - let id = this.route.snapshot.paramMap.get('id'); + const id = this.route.snapshot.paramMap.get('id'); this.hero$ = this.service.getHero(id); } diff --git a/aio/content/examples/router/src/app/heroes/hero-detail/hero-detail.component.3.ts b/aio/content/examples/router/src/app/heroes/hero-detail/hero-detail.component.3.ts index f2dc18af7b..afcb4fa6c5 100644 --- a/aio/content/examples/router/src/app/heroes/hero-detail/hero-detail.component.3.ts +++ b/aio/content/examples/router/src/app/heroes/hero-detail/hero-detail.component.3.ts @@ -37,7 +37,7 @@ export class HeroDetailComponent implements OnInit { // #docregion gotoHeroes gotoHeroes(hero: Hero) { - let heroId = hero ? hero.id : null; + const heroId = hero ? hero.id : null; // Pass along the hero id if available // so that the HeroList component can select that hero. // Include a junk 'foo' property for fun. diff --git a/aio/content/examples/router/src/app/heroes/hero-detail/hero-detail.component.ts b/aio/content/examples/router/src/app/heroes/hero-detail/hero-detail.component.ts index cef9ffb99d..b5114be22d 100644 --- a/aio/content/examples/router/src/app/heroes/hero-detail/hero-detail.component.ts +++ b/aio/content/examples/router/src/app/heroes/hero-detail/hero-detail.component.ts @@ -38,7 +38,7 @@ export class HeroDetailComponent implements OnInit { // #docregion redirect gotoHeroes(hero: Hero) { - let heroId = hero ? hero.id : null; + const heroId = hero ? hero.id : null; // Pass along the hero id if available // so that the HeroList component can select that hero. // Include a junk 'foo' property for fun. diff --git a/aio/content/examples/security/e2e/src/app.e2e-spec.ts b/aio/content/examples/security/e2e/src/app.e2e-spec.ts index 5f22b3f06b..2a071ab074 100644 --- a/aio/content/examples/security/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/security/e2e/src/app.e2e-spec.ts @@ -4,32 +4,32 @@ describe('Security E2E Tests', () => { beforeAll(() => browser.get('')); it('sanitizes innerHTML', () => { - let interpolated = element(By.className('e2e-inner-html-interpolated')); + const interpolated = element(By.className('e2e-inner-html-interpolated')); expect(interpolated.getText()) .toContain('Template Syntax'); - let bound = element(By.className('e2e-inner-html-bound')); + const bound = element(By.className('e2e-inner-html-bound')); expect(bound.getText()).toContain('Template Syntax'); - let bold = element(By.css('.e2e-inner-html-bound b')); + const bold = element(By.css('.e2e-inner-html-bound b')); expect(bold.getText()).toContain('Syntax'); }); it('escapes untrusted URLs', () => { - let untrustedUrl = element(By.className('e2e-dangerous-url')); + const untrustedUrl = element(By.className('e2e-dangerous-url')); expect(untrustedUrl.getAttribute('href')).toMatch(/^unsafe:javascript/); }); it('binds trusted URLs', () => { - let trustedUrl = element(By.className('e2e-trusted-url')); + const trustedUrl = element(By.className('e2e-trusted-url')); expect(trustedUrl.getAttribute('href')).toMatch(/^javascript:alert/); }); it('escapes untrusted resource URLs', () => { - let iframe = element(By.className('e2e-iframe-untrusted-src')); + const iframe = element(By.className('e2e-iframe-untrusted-src')); expect(iframe.getAttribute('src')).toBe(''); }); it('binds trusted resource URLs', () => { - let iframe = element(By.className('e2e-iframe-trusted-src')); + const iframe = element(By.className('e2e-iframe-trusted-src')); expect(iframe.getAttribute('src')).toMatch(/^https:\/\/www.youtube.com\//); }); }); diff --git a/aio/content/examples/service-worker-getting-started/e2e/src/app.e2e-spec.ts b/aio/content/examples/service-worker-getting-started/e2e/src/app.e2e-spec.ts index d2af78e972..bfb5f1c5bb 100755 --- a/aio/content/examples/service-worker-getting-started/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/service-worker-getting-started/e2e/src/app.e2e-spec.ts @@ -15,7 +15,7 @@ describe('sw-example App', () => { }); it('should display the Angular logo', () => { - let logo = element(by.css('img')); + const logo = element(by.css('img')); page.navigateTo(); expect(logo.isPresent()).toBe(true); }); diff --git a/aio/content/examples/set-document-title/e2e/src/app.e2e-spec.ts b/aio/content/examples/set-document-title/e2e/src/app.e2e-spec.ts index 50f3b9db6f..86b9bc76eb 100644 --- a/aio/content/examples/set-document-title/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/set-document-title/e2e/src/app.e2e-spec.ts @@ -6,7 +6,7 @@ describe('Set Document Title', () => { it('should set the document title', () => { - let titles = [ + const titles = [ 'Good morning!', 'Good afternoon!', 'Good evening!' diff --git a/aio/content/examples/setup/e2e/src/app.e2e-spec.ts b/aio/content/examples/setup/e2e/src/app.e2e-spec.ts index 96454e8a8f..560d326a55 100644 --- a/aio/content/examples/setup/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/setup/e2e/src/app.e2e-spec.ts @@ -2,7 +2,7 @@ import { browser, element, by } from 'protractor'; describe('QuickStart E2E Tests', () => { - let expectedMsg = 'Hello Angular'; + const expectedMsg = 'Hello Angular'; beforeEach(() => { browser.get(''); diff --git a/aio/content/examples/styleguide/e2e/src/app.e2e-spec.ts b/aio/content/examples/styleguide/e2e/src/app.e2e-spec.ts index a6fbe26fdb..fb1f35730d 100644 --- a/aio/content/examples/styleguide/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/styleguide/e2e/src/app.e2e-spec.ts @@ -4,7 +4,7 @@ describe('Style Guide', () => { it('01-01', () => { browser.get('#/01-01'); - let pre = element(by.tagName('toh-heroes > pre')); + const pre = element(by.tagName('toh-heroes > pre')); expect(pre.getText()).toContain('Bombasto'); expect(pre.getText()).toContain('Tornado'); expect(pre.getText()).toContain('Magneta'); @@ -13,8 +13,8 @@ describe('Style Guide', () => { it('02-07', () => { browser.get('#/02-07'); - let hero = element(by.tagName('toh-hero > div')); - let users = element(by.tagName('admin-users > div')); + const hero = element(by.tagName('toh-hero > div')); + const users = element(by.tagName('admin-users > div')); expect(hero.getText()).toBe('hero component'); expect(users.getText()).toBe('users component'); @@ -23,77 +23,77 @@ describe('Style Guide', () => { it('02-08', () => { browser.get('#/02-08'); - let input = element(by.tagName('input[tohvalidate]')); + const input = element(by.tagName('input[tohvalidate]')); expect(input.isPresent()).toBe(true); }); it('04-10', () => { browser.get('#/04-10'); - let div = element(by.tagName('sg-app > toh-heroes > div')); + const div = element(by.tagName('sg-app > toh-heroes > div')); expect(div.getText()).toBe('This is heroes component'); }); it('05-02', () => { browser.get('#/05-02'); - let button = element(by.tagName('sg-app > toh-hero-button > button')); + const button = element(by.tagName('sg-app > toh-hero-button > button')); expect(button.getText()).toBe('Hero button'); }); it('05-03', () => { browser.get('#/05-03'); - let button = element(by.tagName('sg-app > toh-hero-button > button')); + const button = element(by.tagName('sg-app > toh-hero-button > button')); expect(button.getText()).toBe('Hero button'); }); it('05-04', () => { browser.get('#/05-04'); - let h2 = element(by.tagName('sg-app > toh-heroes > div > h2')); + const h2 = element(by.tagName('sg-app > toh-heroes > div > h2')); expect(h2.getText()).toBe('My Heroes'); }); it('05-12', () => { browser.get('#/05-12'); - let button = element(by.tagName('sg-app > toh-hero-button > button')); + const button = element(by.tagName('sg-app > toh-hero-button > button')); expect(button.getText()).toBe('OK'); }); it('05-13', () => { browser.get('#/05-13'); - let button = element(by.tagName('sg-app > toh-hero-button > button')); + const button = element(by.tagName('sg-app > toh-hero-button > button')); expect(button.getText()).toBe('OK'); }); it('05-14', () => { browser.get('#/05-14'); - let toast = element(by.tagName('sg-app > toh-toast')); + const toast = element(by.tagName('sg-app > toh-toast')); expect(toast.getText()).toBe('...'); }); it('05-15', () => { browser.get('#/05-15'); - let heroList = element(by.tagName('sg-app > toh-hero-list')); + const heroList = element(by.tagName('sg-app > toh-hero-list')); expect(heroList.getText()).toBe('...'); }); it('05-16', () => { browser.get('#/05-16'); - let hero = element(by.tagName('sg-app > toh-hero')); + const hero = element(by.tagName('sg-app > toh-hero')); expect(hero.getText()).toBe('...'); }); it('05-17', () => { browser.get('#/05-17'); - let section = element(by.tagName('sg-app > toh-hero-list > section')); + const section = element(by.tagName('sg-app > toh-hero-list > section')); expect(section.getText()).toContain('Our list of heroes'); expect(section.getText()).toContain('Total powers'); expect(section.getText()).toContain('Average power'); @@ -102,14 +102,14 @@ describe('Style Guide', () => { it('06-01', () => { browser.get('#/06-01'); - let div = element(by.tagName('sg-app > div[tohhighlight]')); + const div = element(by.tagName('sg-app > div[tohhighlight]')); expect(div.getText()).toBe('Bombasta'); }); it('06-03', () => { browser.get('#/06-03'); - let input = element(by.tagName('input[tohvalidator]')); + const input = element(by.tagName('input[tohvalidator]')); expect(input.isPresent()).toBe(true); }); @@ -117,7 +117,7 @@ describe('Style Guide', () => { xit('07-01', () => { browser.get('#/07-01'); - let lis = element.all(by.tagName('sg-app > ul > li')); + const lis = element.all(by.tagName('sg-app > ul > li')); expect(lis.get(0).getText()).toBe('Windstorm'); expect(lis.get(1).getText()).toBe('Bombasto'); expect(lis.get(2).getText()).toBe('Magneta'); @@ -127,21 +127,21 @@ describe('Style Guide', () => { it('07-03', () => { browser.get('#/07-03'); - let pre = element(by.tagName('toh-heroes > pre')); + const pre = element(by.tagName('toh-heroes > pre')); expect(pre.getText()).toContain('[]'); }); it('07-04', () => { browser.get('#/07-04'); - let pre = element(by.tagName('toh-app > pre')); + const pre = element(by.tagName('toh-app > pre')); expect(pre.getText()).toContain('[]'); }); it('09-01', () => { browser.get('#/09-01'); - let button = element(by.tagName('sg-app > toh-hero-button > button')); + const button = element(by.tagName('sg-app > toh-hero-button > button')); expect(button.getText()).toBe('OK'); }); }); diff --git a/aio/content/examples/styleguide/src/04-10/app/shared/filter-text/filter-text.service.ts b/aio/content/examples/styleguide/src/04-10/app/shared/filter-text/filter-text.service.ts index 7de3b3ce33..131c79ad64 100644 --- a/aio/content/examples/styleguide/src/04-10/app/shared/filter-text/filter-text.service.ts +++ b/aio/content/examples/styleguide/src/04-10/app/shared/filter-text/filter-text.service.ts @@ -11,9 +11,9 @@ export class FilterTextService { let filteredList: any[]; if (data && props && originalList) { data = data.toLowerCase(); - let filtered = originalList.filter(item => { + const filtered = originalList.filter(item => { let match = false; - for (let prop of props) { + for (const prop of props) { if (item[prop].toString().toLowerCase().indexOf(data) > -1) { match = true; break; diff --git a/aio/content/examples/styleguide/src/05-15/app/heroes/shared/hero.service.ts b/aio/content/examples/styleguide/src/05-15/app/heroes/shared/hero.service.ts index 3f8e476766..94bdf2615c 100644 --- a/aio/content/examples/styleguide/src/05-15/app/heroes/shared/hero.service.ts +++ b/aio/content/examples/styleguide/src/05-15/app/heroes/shared/hero.service.ts @@ -8,7 +8,7 @@ import { Hero } from './hero.model'; @Injectable() export class HeroService { getHeroes() { - let heroes: Hero[] = []; + const heroes: Hero[] = []; return of(heroes); } } diff --git a/aio/content/examples/styleguide/src/07-03/app/heroes/shared/hero.service.ts b/aio/content/examples/styleguide/src/07-03/app/heroes/shared/hero.service.ts index d3d8857caa..02bc7f6f0b 100644 --- a/aio/content/examples/styleguide/src/07-03/app/heroes/shared/hero.service.ts +++ b/aio/content/examples/styleguide/src/07-03/app/heroes/shared/hero.service.ts @@ -10,7 +10,7 @@ import { Hero } from './hero.model'; }) export class HeroService { getHeroes() { - let heroes: Hero[] = []; + const heroes: Hero[] = []; return of(heroes); } } diff --git a/aio/content/examples/styleguide/src/07-04/app/heroes/shared/hero.service.ts b/aio/content/examples/styleguide/src/07-04/app/heroes/shared/hero.service.ts index 3f8e476766..94bdf2615c 100644 --- a/aio/content/examples/styleguide/src/07-04/app/heroes/shared/hero.service.ts +++ b/aio/content/examples/styleguide/src/07-04/app/heroes/shared/hero.service.ts @@ -8,7 +8,7 @@ import { Hero } from './hero.model'; @Injectable() export class HeroService { getHeroes() { - let heroes: Hero[] = []; + const heroes: Hero[] = []; return of(heroes); } } diff --git a/aio/content/examples/styleguide/src/app/hero-data.ts b/aio/content/examples/styleguide/src/app/hero-data.ts index f3e6feb91c..893b5f8b8d 100644 --- a/aio/content/examples/styleguide/src/app/hero-data.ts +++ b/aio/content/examples/styleguide/src/app/hero-data.ts @@ -1,6 +1,6 @@ export class HeroData { createDb() { - let heroes = [ + const heroes = [ { id: 1, name: 'Windstorm' }, { id: 2, name: 'Bombasto' }, { id: 3, name: 'Magneta' }, diff --git a/aio/content/examples/template-expression-operators/e2e/src/app.e2e-spec.ts b/aio/content/examples/template-expression-operators/e2e/src/app.e2e-spec.ts index 6bfd7c8539..1cc2511ad9 100644 --- a/aio/content/examples/template-expression-operators/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/template-expression-operators/e2e/src/app.e2e-spec.ts @@ -8,22 +8,22 @@ describe('Template Expression Operators', () => { }); it('should have title Inputs and Outputs', () => { - let title = element.all(by.css('h1')).get(0); + const title = element.all(by.css('h1')).get(0); expect(title.getText()).toEqual('Template Expression Operators'); }); it('should display json data', () => { - let jsonDate = element.all(by.css('p')).get(4); + const jsonDate = element.all(by.css('p')).get(4); expect(jsonDate.getText()).toContain('1980'); }); it('should display $98', () => { - let jsonDate = element.all(by.css('p')).get(5); + const jsonDate = element.all(by.css('p')).get(5); expect(jsonDate.getText()).toContain('$98.00'); }); it('should display Telephone', () => { - let jsonDate = element.all(by.css('p')).get(6); + const jsonDate = element.all(by.css('p')).get(6); expect(jsonDate.getText()).toContain('Telephone'); }); diff --git a/aio/content/examples/template-reference-variables/e2e/src/app.e2e-spec.ts b/aio/content/examples/template-reference-variables/e2e/src/app.e2e-spec.ts index 3eefa04e5f..6b0cb6bd54 100644 --- a/aio/content/examples/template-reference-variables/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/template-reference-variables/e2e/src/app.e2e-spec.ts @@ -21,8 +21,8 @@ describe('Template-reference-variables-example', () => { }); it('should log a Calling 123 ... message', async () => { - let callButton = element.all(by.css('button')).get(0); - let phoneInput = element.all(by.css('input')).get(0); + const callButton = element.all(by.css('button')).get(0); + const phoneInput = element.all(by.css('input')).get(0); await phoneInput.sendKeys('123'); await callButton.click(); const contents = 'Calling 123 ...'; @@ -30,8 +30,8 @@ describe('Template-reference-variables-example', () => { }); it('should log a Faxing 123 ... message', async () => { - let faxButton = element.all(by.css('button')).get(1); - let faxInput = element.all(by.css('input')).get(1); + const faxButton = element.all(by.css('button')).get(1); + const faxInput = element.all(by.css('input')).get(1); await faxInput.sendKeys('123'); await faxButton.click(); const contents = 'Faxing 123 ...'; @@ -39,13 +39,13 @@ describe('Template-reference-variables-example', () => { }); it('should display a disabled button', () => { - let disabledButton = element.all(by.css('button')).get(2); + const disabledButton = element.all(by.css('button')).get(2); expect(disabledButton.isEnabled()).toBe(false); }); it('should submit form', async () => { - let submitButton = element.all(by.css('button')).get(3); - let nameInput = element.all(by.css('input')).get(2); + const submitButton = element.all(by.css('button')).get(3); + const nameInput = element.all(by.css('input')).get(2); await nameInput.sendKeys('123'); await submitButton.click(); expect(element.all(by.css('div > p')).get(2).getText()).toEqual('Submitted. Form value is {"name":"123"}'); diff --git a/aio/content/examples/testing/e2e/src/app.e2e-spec.ts b/aio/content/examples/testing/e2e/src/app.e2e-spec.ts index bc2092251a..b06b7a095d 100644 --- a/aio/content/examples/testing/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/testing/e2e/src/app.e2e-spec.ts @@ -6,7 +6,7 @@ describe('Testing Example', () => { beforeAll(() => browser.get('')); function getPageElts() { - let navElts = element.all(by.css('app-root nav a')); + const navElts = element.all(by.css('app-root nav a')); return { navElts, @@ -20,13 +20,13 @@ describe('Testing Example', () => { }); it(`has views ${expectedViewNames}`, async () => { - let viewNames = getPageElts().navElts.map(async (el: ElementFinder) => await el.getText()); + const viewNames = getPageElts().navElts.map(async (el: ElementFinder) => await el.getText()); expect(viewNames).toEqual(expectedViewNames); }); it('has dashboard as the active view', () => { - let page = getPageElts(); + const page = getPageElts(); expect(page.appDashboard.isPresent()).toBeTruthy(); }); diff --git a/aio/content/examples/testing/src/app/dashboard/dashboard.component.ts b/aio/content/examples/testing/src/app/dashboard/dashboard.component.ts index 397add79e1..9a65b04789 100644 --- a/aio/content/examples/testing/src/app/dashboard/dashboard.component.ts +++ b/aio/content/examples/testing/src/app/dashboard/dashboard.component.ts @@ -28,13 +28,13 @@ export class DashboardComponent implements OnInit { // #docregion goto-detail gotoDetail(hero: Hero) { - let url = `/heroes/${hero.id}`; + const url = `/heroes/${hero.id}`; this.router.navigateByUrl(url); } // #enddocregion goto-detail get title() { - let cnt = this.heroes.length; + const cnt = this.heroes.length; return cnt === 0 ? 'No Heroes' : cnt === 1 ? 'Top Hero' : `Top ${cnt} Heroes`; } diff --git a/aio/content/examples/testing/src/app/demo/demo.ts b/aio/content/examples/testing/src/app/demo/demo.ts index b51ee5c6bc..e97ccb387c 100644 --- a/aio/content/examples/testing/src/app/demo/demo.ts +++ b/aio/content/examples/testing/src/app/demo/demo.ts @@ -310,11 +310,11 @@ export class MyIfChildComponent implements OnInit, OnChanges, OnDestroy { } ngOnChanges(changes: {[propertyName: string]: SimpleChange}) { - for (let propName in changes) { + for (const propName in changes) { this.ngOnChangesCounter += 1; - let prop = changes[propName]; - let cur = JSON.stringify(prop.currentValue); - let prev = JSON.stringify(prop.previousValue); + const prop = changes[propName]; + const cur = JSON.stringify(prop.currentValue); + const prev = JSON.stringify(prop.previousValue); this.changeLog.push(`${propName}: currentValue = ${cur}, previousValue = ${prev}`); } } diff --git a/aio/content/examples/testing/src/app/model/testing/http-client.spec.ts b/aio/content/examples/testing/src/app/model/testing/http-client.spec.ts index abb4f996d8..cb986f62eb 100644 --- a/aio/content/examples/testing/src/app/model/testing/http-client.spec.ts +++ b/aio/content/examples/testing/src/app/model/testing/http-client.spec.ts @@ -89,7 +89,7 @@ describe('HttpClient testing', () => { }); it('can test multiple requests', () => { - let testData: Data[] = [ + const testData: Data[] = [ { name: 'bob' }, { name: 'carol' }, { name: 'ted' }, { name: 'alice' } ]; diff --git a/aio/content/examples/testing/src/app/shared/title-case.pipe.spec.ts b/aio/content/examples/testing/src/app/shared/title-case.pipe.spec.ts index 5dfc5d91b0..2d32454848 100644 --- a/aio/content/examples/testing/src/app/shared/title-case.pipe.spec.ts +++ b/aio/content/examples/testing/src/app/shared/title-case.pipe.spec.ts @@ -5,7 +5,7 @@ import { TitleCasePipe } from './title-case.pipe'; // #docregion excerpt, mini-excerpt describe('TitleCasePipe', () => { // This pipe is a pure, stateless function so no need for BeforeEach - let pipe = new TitleCasePipe(); + const pipe = new TitleCasePipe(); it('transforms "abc" to "Abc"', () => { expect(pipe.transform('abc')).toBe('Abc'); diff --git a/aio/content/examples/testing/src/testing/index.ts b/aio/content/examples/testing/src/testing/index.ts index 2465b2a4a2..e9e139a906 100644 --- a/aio/content/examples/testing/src/testing/index.ts +++ b/aio/content/examples/testing/src/testing/index.ts @@ -21,7 +21,7 @@ export function advance(f: ComponentFixture): void { * Although officially deprecated, some browsers (phantom) don't accept the preferred "new Event(eventName)" */ export function newEvent(eventName: string, bubbles = false, cancelable = false) { - let evt = document.createEvent('CustomEvent'); // MUST be 'CustomEvent' + const evt = document.createEvent('CustomEvent'); // MUST be 'CustomEvent' evt.initCustomEvent(eventName, bubbles, cancelable, null); return evt; } diff --git a/aio/content/examples/toh-pt0/e2e/src/app.e2e-spec.ts b/aio/content/examples/toh-pt0/e2e/src/app.e2e-spec.ts index 01828f9f1a..e05a1b4b21 100644 --- a/aio/content/examples/toh-pt0/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/toh-pt0/e2e/src/app.e2e-spec.ts @@ -4,7 +4,7 @@ describe('Tour of Heroes', () => { beforeEach(() => browser.get('/')); it('should display "Tour of Heroes"', () => { - let title = element(by.css('app-root h1')).getText(); + const title = element(by.css('app-root h1')).getText(); expect(title).toEqual('Tour of Heroes'); }); }); diff --git a/aio/content/examples/toh-pt1/e2e/src/app.e2e-spec.ts b/aio/content/examples/toh-pt1/e2e/src/app.e2e-spec.ts index 6b68069429..6d9cd078b6 100644 --- a/aio/content/examples/toh-pt1/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/toh-pt1/e2e/src/app.e2e-spec.ts @@ -12,9 +12,9 @@ class Hero { // Get hero id and name from the given detail element. static async fromDetail(detail: ElementFinder): Promise { // Get hero id from the first
- let id = await detail.all(by.css('div')).first().getText(); + const id = await detail.all(by.css('div')).first().getText(); // Get name from the h2 - let name = await detail.element(by.css('h2')).getText(); + const name = await detail.element(by.css('h2')).getText(); return { id: +id.substr(id.indexOf(' ') + 1), name: name.substr(0, name.lastIndexOf(' ')) @@ -24,7 +24,7 @@ class Hero { const nameSuffix = 'X'; function addToHeroName(text: string): promise.Promise { - let input = element(by.css('input')); + const input = element(by.css('input')); return input.sendKeys(text); } @@ -39,22 +39,22 @@ describe('Tutorial part 1', () => { }); it(`has h1 '${expectedH1}'`, () => { - let hText = element(by.css('h1')).getText(); + const hText = element(by.css('h1')).getText(); expect(hText).toEqual(expectedH1, 'h1'); }); it(`shows initial hero details`, async () => { - let page = getPageElts(); - let hero = await Hero.fromDetail(page.heroDetail); + const page = getPageElts(); + const hero = await Hero.fromDetail(page.heroDetail); expect(hero.id).toEqual(expectedHero.id); expect(hero.name).toEqual(expectedHero.name.toUpperCase()); }); it(`shows updated hero name`, async () => { addToHeroName(nameSuffix); - let page = getPageElts(); - let hero = await Hero.fromDetail(page.heroDetail); - let newName = expectedHero.name + nameSuffix; + const page = getPageElts(); + const hero = await Hero.fromDetail(page.heroDetail); + const newName = expectedHero.name + nameSuffix; expect(hero.id).toEqual(expectedHero.id); expect(hero.name).toEqual(newName.toUpperCase()); }); diff --git a/aio/content/examples/toh-pt2/e2e/src/app.e2e-spec.ts b/aio/content/examples/toh-pt2/e2e/src/app.e2e-spec.ts index 563419cde0..acc6f83229 100644 --- a/aio/content/examples/toh-pt2/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/toh-pt2/e2e/src/app.e2e-spec.ts @@ -24,9 +24,9 @@ class Hero { // Get hero id and name from the given detail element. static async fromDetail(detail: ElementFinder): Promise { // Get hero id from the first
- let id = await detail.all(by.css('div')).first().getText(); + const id = await detail.all(by.css('div')).first().getText(); // Get name from the h2 - let name = await detail.element(by.css('h2')).getText(); + const name = await detail.element(by.css('h2')).getText(); return { id: +id.substr(id.indexOf(' ') + 1), name: name.substr(0, name.lastIndexOf(' ')) @@ -55,12 +55,12 @@ function initialPageTests() { }); it('has the right number of heroes', () => { - let page = getPageElts(); + const page = getPageElts(); expect(page.heroes.count()).toEqual(10); }); it('has no selected hero and no hero details', () => { - let page = getPageElts(); + const page = getPageElts(); expect(page.selected.isPresent()).toBeFalsy('selected hero'); expect(page.heroDetail.isPresent()).toBeFalsy('no hero detail'); }); @@ -68,20 +68,20 @@ function initialPageTests() { function selectHeroTests() { it(`selects ${targetHero.name} from hero list`, () => { - let hero = element(by.cssContainingText('li span.badge', targetHero.id.toString())); + const hero = element(by.cssContainingText('li span.badge', targetHero.id.toString())); hero.click(); // Nothing specific to expect other than lack of exceptions. }); it(`has selected ${targetHero.name}`, () => { - let page = getPageElts(); - let expectedText = `${targetHero.id} ${targetHero.name}`; + const page = getPageElts(); + const expectedText = `${targetHero.id} ${targetHero.name}`; expect(page.selected.getText()).toBe(expectedText); }); it('shows selected hero details', async () => { - let page = getPageElts(); - let hero = await Hero.fromDetail(page.heroDetail); + const page = getPageElts(); + const hero = await Hero.fromDetail(page.heroDetail); expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(targetHero.name.toUpperCase()); }); @@ -94,17 +94,17 @@ function updateHeroTests() { }); it(`shows updated hero name in details`, async () => { - let page = getPageElts(); - let hero = await Hero.fromDetail(page.heroDetail); - let newName = targetHero.name + nameSuffix; + const page = getPageElts(); + const hero = await Hero.fromDetail(page.heroDetail); + const newName = targetHero.name + nameSuffix; expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(newName.toUpperCase()); }); it(`shows updated hero name in list`, async () => { - let page = getPageElts(); - let hero = Hero.fromString(await page.selected.getText()); - let newName = targetHero.name + nameSuffix; + const page = getPageElts(); + const hero = Hero.fromString(await page.selected.getText()); + const newName = targetHero.name + nameSuffix; expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(newName); }); @@ -112,13 +112,13 @@ function updateHeroTests() { } function addToHeroName(text: string): promise.Promise { - let input = element(by.css('input')); + const input = element(by.css('input')); return input.sendKeys(text); } function expectHeading(hLevel: number, expectedText: string): void { - let hTag = `h${hLevel}`; - let hText = element(by.css(hTag)).getText(); + const hTag = `h${hLevel}`; + const hText = element(by.css(hTag)).getText(); expect(hText).toEqual(expectedText, hTag); } diff --git a/aio/content/examples/toh-pt3/e2e/src/app.e2e-spec.ts b/aio/content/examples/toh-pt3/e2e/src/app.e2e-spec.ts index 6cc55b0cd2..4eb601fee6 100644 --- a/aio/content/examples/toh-pt3/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/toh-pt3/e2e/src/app.e2e-spec.ts @@ -24,9 +24,9 @@ class Hero { // Get hero id and name from the given detail element. static async fromDetail(detail: ElementFinder): Promise { // Get hero id from the first
- let id = await detail.all(by.css('div')).first().getText(); + const id = await detail.all(by.css('div')).first().getText(); // Get name from the h2 - let name = await detail.element(by.css('h2')).getText(); + const name = await detail.element(by.css('h2')).getText(); return { id: +id.substr(id.indexOf(' ') + 1), name: name.substr(0, name.lastIndexOf(' ')) @@ -55,12 +55,12 @@ function initialPageTests() { }); it('has the right number of heroes', () => { - let page = getPageElts(); + const page = getPageElts(); expect(page.heroes.count()).toEqual(10); }); it('has no selected hero and no hero details', () => { - let page = getPageElts(); + const page = getPageElts(); expect(page.selected.isPresent()).toBeFalsy('selected hero'); expect(page.heroDetail.isPresent()).toBeFalsy('no hero detail'); }); @@ -68,20 +68,20 @@ function initialPageTests() { function selectHeroTests() { it(`selects ${targetHero.name} from hero list`, () => { - let hero = element(by.cssContainingText('li span.badge', targetHero.id.toString())); + const hero = element(by.cssContainingText('li span.badge', targetHero.id.toString())); hero.click(); // Nothing specific to expect other than lack of exceptions. }); it(`has selected ${targetHero.name}`, () => { - let page = getPageElts(); - let expectedText = `${targetHero.id} ${targetHero.name}`; + const page = getPageElts(); + const expectedText = `${targetHero.id} ${targetHero.name}`; expect(page.selected.getText()).toBe(expectedText); }); it('shows selected hero details', async () => { - let page = getPageElts(); - let hero = await Hero.fromDetail(page.heroDetail); + const page = getPageElts(); + const hero = await Hero.fromDetail(page.heroDetail); expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(targetHero.name.toUpperCase()); }); @@ -94,17 +94,17 @@ function updateHeroTests() { }); it(`shows updated hero name in details`, async () => { - let page = getPageElts(); - let hero = await Hero.fromDetail(page.heroDetail); - let newName = targetHero.name + nameSuffix; + const page = getPageElts(); + const hero = await Hero.fromDetail(page.heroDetail); + const newName = targetHero.name + nameSuffix; expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(newName.toUpperCase()); }); it(`shows updated hero name in list`, async () => { - let page = getPageElts(); - let hero = Hero.fromString(await page.selected.getText()); - let newName = targetHero.name + nameSuffix; + const page = getPageElts(); + const hero = Hero.fromString(await page.selected.getText()); + const newName = targetHero.name + nameSuffix; expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(newName); }); @@ -112,13 +112,13 @@ function updateHeroTests() { } function addToHeroName(text: string): promise.Promise { - let input = element(by.css('input')); + const input = element(by.css('input')); return input.sendKeys(text); } function expectHeading(hLevel: number, expectedText: string): void { - let hTag = `h${hLevel}`; - let hText = element(by.css(hTag)).getText(); + const hTag = `h${hLevel}`; + const hText = element(by.css(hTag)).getText(); expect(hText).toEqual(expectedText, hTag); } diff --git a/aio/content/examples/toh-pt4/e2e/src/app.e2e-spec.ts b/aio/content/examples/toh-pt4/e2e/src/app.e2e-spec.ts index 66e4f51fd4..02330926af 100644 --- a/aio/content/examples/toh-pt4/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/toh-pt4/e2e/src/app.e2e-spec.ts @@ -24,9 +24,9 @@ class Hero { // Get hero id and name from the given detail element. static async fromDetail(detail: ElementFinder): Promise { // Get hero id from the first
- let id = await detail.all(by.css('div')).first().getText(); + const id = await detail.all(by.css('div')).first().getText(); // Get name from the h2 - let name = await detail.element(by.css('h2')).getText(); + const name = await detail.element(by.css('h2')).getText(); return { id: +id.substr(id.indexOf(' ') + 1), name: name.substr(0, name.lastIndexOf(' ')) @@ -55,12 +55,12 @@ function initialPageTests() { }); it('has the right number of heroes', () => { - let page = getPageElts(); + const page = getPageElts(); expect(page.heroes.count()).toEqual(10); }); it('has no selected hero and no hero details', () => { - let page = getPageElts(); + const page = getPageElts(); expect(page.selected.isPresent()).toBeFalsy('selected hero'); expect(page.heroDetail.isPresent()).toBeFalsy('no hero detail'); }); @@ -68,21 +68,21 @@ function initialPageTests() { function selectHeroTests() { it(`selects ${targetHero.name} from hero list`, () => { - let hero = element(by.cssContainingText('li span.badge', targetHero.id.toString())); + const hero = element(by.cssContainingText('li span.badge', targetHero.id.toString())); hero.click(); // Nothing specific to expect other than lack of exceptions. }); it(`has selected ${targetHero.name}`, () => { - let page = getPageElts(); - let expectedText = `${targetHero.id} ${targetHero.name}`; + const page = getPageElts(); + const expectedText = `${targetHero.id} ${targetHero.name}`; expect(page.selected.getText()).toBe(expectedText); }); it('shows selected hero details', async () => { - let page = getPageElts(); - let message = getMessage(); - let hero = await Hero.fromDetail(page.heroDetail); + const page = getPageElts(); + const message = getMessage(); + const hero = await Hero.fromDetail(page.heroDetail); expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(targetHero.name.toUpperCase()); // Message text contain id number matches the hero.id number @@ -98,17 +98,17 @@ function updateHeroTests() { }); it(`shows updated hero name in details`, async () => { - let page = getPageElts(); - let hero = await Hero.fromDetail(page.heroDetail); - let newName = targetHero.name + nameSuffix; + const page = getPageElts(); + const hero = await Hero.fromDetail(page.heroDetail); + const newName = targetHero.name + nameSuffix; expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(newName.toUpperCase()); }); it(`shows updated hero name in list`, async () => { - let page = getPageElts(); - let hero = Hero.fromString(await page.selected.getText()); - let newName = targetHero.name + nameSuffix; + const page = getPageElts(); + const hero = Hero.fromString(await page.selected.getText()); + const newName = targetHero.name + nameSuffix; expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(newName); }); @@ -116,13 +116,13 @@ function updateHeroTests() { } function addToHeroName(text: string): promise.Promise { - let input = element(by.css('input')); + const input = element(by.css('input')); return input.sendKeys(text); } function expectHeading(hLevel: number, expectedText: string): void { - let hTag = `h${hLevel}`; - let hText = element(by.css(hTag)).getText(); + const hTag = `h${hLevel}`; + const hText = element(by.css(hTag)).getText(); expect(hText).toEqual(expectedText, hTag); } @@ -135,7 +135,7 @@ function getPageElts() { } function getMessage() { - let hero = element(by.cssContainingText('li span.badge', targetHero.id.toString())); + const hero = element(by.cssContainingText('li span.badge', targetHero.id.toString())); hero.click(); return element.all(by.css('app-root > app-messages > div > div')).get(1); } diff --git a/aio/content/examples/toh-pt5/e2e/src/app.e2e-spec.ts b/aio/content/examples/toh-pt5/e2e/src/app.e2e-spec.ts index ab6431ea7f..ff0c0b5ff7 100644 --- a/aio/content/examples/toh-pt5/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/toh-pt5/e2e/src/app.e2e-spec.ts @@ -25,9 +25,9 @@ class Hero { // Get hero id and name from the given detail element. static async fromDetail(detail: ElementFinder): Promise { // Get hero id from the first
- let id = await detail.all(by.css('div')).first().getText(); + const id = await detail.all(by.css('div')).first().getText(); // Get name from the h2 - let name = await detail.element(by.css('h2')).getText(); + const name = await detail.element(by.css('h2')).getText(); return { id: +id.substr(id.indexOf(' ') + 1), name: name.substr(0, name.lastIndexOf(' ')) @@ -40,7 +40,7 @@ describe('Tutorial part 5', () => { beforeAll(() => browser.get('')); function getPageElts() { - let navElts = element.all(by.css('app-root nav a')); + const navElts = element.all(by.css('app-root nav a')); return { navElts, @@ -68,12 +68,12 @@ describe('Tutorial part 5', () => { const expectedViewNames = ['Dashboard', 'Heroes']; it(`has views ${expectedViewNames}`, () => { - let viewNames = getPageElts().navElts.map((el: ElementFinder) => el.getText()); + const viewNames = getPageElts().navElts.map((el: ElementFinder) => el.getText()); expect(viewNames).toEqual(expectedViewNames); }); it('has dashboard as the active view', () => { - let page = getPageElts(); + const page = getPageElts(); expect(page.appDashboard.isPresent()).toBeTruthy(); }); @@ -84,7 +84,7 @@ describe('Tutorial part 5', () => { beforeAll(() => browser.get('')); it('has top heroes', () => { - let page = getPageElts(); + const page = getPageElts(); expect(page.topHeroes.count()).toEqual(4); }); @@ -94,7 +94,7 @@ describe('Tutorial part 5', () => { it(`saves and shows ${newHeroName} in Dashboard`, () => { element(by.buttonText('go back')).click(); - let targetHeroElt = getPageElts().topHeroes.get(targetHeroDashboardIndex); + const targetHeroElt = getPageElts().topHeroes.get(targetHeroDashboardIndex); expect(targetHeroElt.getText()).toEqual(newHeroName); }); @@ -106,7 +106,7 @@ describe('Tutorial part 5', () => { it('can switch to Heroes view', () => { getPageElts().appHeroesHref.click(); - let page = getPageElts(); + const page = getPageElts(); expect(page.appHeroes.isPresent()).toBeTruthy(); expect(page.allHeroes.count()).toEqual(10, 'number of heroes'); }); @@ -114,9 +114,9 @@ describe('Tutorial part 5', () => { it('can route to hero details', async () => { getHeroLiEltById(targetHero.id).click(); - let page = getPageElts(); + const page = getPageElts(); expect(page.heroDetail.isPresent()).toBeTruthy('shows hero detail'); - let hero = await Hero.fromDetail(page.heroDetail); + const hero = await Hero.fromDetail(page.heroDetail); expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(targetHero.name.toUpperCase()); }); @@ -125,20 +125,20 @@ describe('Tutorial part 5', () => { it(`shows ${newHeroName} in Heroes list`, () => { element(by.buttonText('go back')).click(); - let expectedText = `${targetHero.id} ${newHeroName}`; + const expectedText = `${targetHero.id} ${newHeroName}`; expect(getHeroLiEltById(targetHero.id).getText()).toEqual(expectedText); }); }); async function dashboardSelectTargetHero() { - let targetHeroElt = getPageElts().topHeroes.get(targetHeroDashboardIndex); + const targetHeroElt = getPageElts().topHeroes.get(targetHeroDashboardIndex); expect(targetHeroElt.getText()).toEqual(targetHero.name); targetHeroElt.click(); - let page = getPageElts(); + const page = getPageElts(); expect(page.heroDetail.isPresent()).toBeTruthy('shows hero detail'); - let hero = await Hero.fromDetail(page.heroDetail); + const hero = await Hero.fromDetail(page.heroDetail); expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(targetHero.name.toUpperCase()); } @@ -147,8 +147,8 @@ describe('Tutorial part 5', () => { // Assumes that the current view is the hero details view. addToHeroName(nameSuffix); - let page = getPageElts(); - let hero = await Hero.fromDetail(page.heroDetail); + const page = getPageElts(); + const hero = await Hero.fromDetail(page.heroDetail); expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(newHeroName.toUpperCase()); } @@ -156,17 +156,17 @@ describe('Tutorial part 5', () => { }); function addToHeroName(text: string): promise.Promise { - let input = element(by.css('input')); + const input = element(by.css('input')); return input.sendKeys(text); } function expectHeading(hLevel: number, expectedText: string): void { - let hTag = `h${hLevel}`; - let hText = element(by.css(hTag)).getText(); + const hTag = `h${hLevel}`; + const hText = element(by.css(hTag)).getText(); expect(hText).toEqual(expectedText, hTag); } function getHeroLiEltById(id: number) { - let spanForId = element(by.cssContainingText('li span.badge', id.toString())); + const spanForId = element(by.cssContainingText('li span.badge', id.toString())); return spanForId.element(by.xpath('..')); } diff --git a/aio/content/examples/toh-pt6/e2e/src/app.e2e-spec.ts b/aio/content/examples/toh-pt6/e2e/src/app.e2e-spec.ts index 860516e300..58f5677d9d 100644 --- a/aio/content/examples/toh-pt6/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/toh-pt6/e2e/src/app.e2e-spec.ts @@ -24,17 +24,17 @@ class Hero { // Hero from hero list
  • element. static async fromLi(li: ElementFinder): Promise { - let stringsFromA = await li.all(by.css('a')).getText(); - let strings = stringsFromA[0].split(' '); + const stringsFromA = await li.all(by.css('a')).getText(); + const strings = stringsFromA[0].split(' '); return { id: +strings[0], name: strings[1] }; } // Hero id and name from the given detail element. static async fromDetail(detail: ElementFinder): Promise { // Get hero id from the first
    - let id = await detail.all(by.css('div')).first().getText(); + const id = await detail.all(by.css('div')).first().getText(); // Get name from the h2 - let name = await detail.element(by.css('h2')).getText(); + const name = await detail.element(by.css('h2')).getText(); return { id: +id.substr(id.indexOf(' ') + 1), name: name.substr(0, name.lastIndexOf(' ')) @@ -47,7 +47,7 @@ describe('Tutorial part 6', () => { beforeAll(() => browser.get('')); function getPageElts() { - let navElts = element.all(by.css('app-root nav a')); + const navElts = element.all(by.css('app-root nav a')); return { navElts, @@ -80,12 +80,12 @@ describe('Tutorial part 6', () => { const expectedViewNames = ['Dashboard', 'Heroes']; it(`has views ${expectedViewNames}`, () => { - let viewNames = getPageElts().navElts.map((el: ElementFinder) => el.getText()); + const viewNames = getPageElts().navElts.map((el: ElementFinder) => el.getText()); expect(viewNames).toEqual(expectedViewNames); }); it('has dashboard as the active view', () => { - let page = getPageElts(); + const page = getPageElts(); expect(page.appDashboard.isPresent()).toBeTruthy(); }); @@ -96,7 +96,7 @@ describe('Tutorial part 6', () => { beforeAll(() => browser.get('')); it('has top heroes', () => { - let page = getPageElts(); + const page = getPageElts(); expect(page.topHeroes.count()).toEqual(4); }); @@ -108,7 +108,7 @@ describe('Tutorial part 6', () => { element(by.buttonText('go back')).click(); browser.waitForAngular(); // seems necessary to gets tests to pass for toh-pt6 - let targetHeroElt = getPageElts().topHeroes.get(targetHeroDashboardIndex); + const targetHeroElt = getPageElts().topHeroes.get(targetHeroDashboardIndex); expect(targetHeroElt.getText()).toEqual(targetHero.name); }); @@ -120,7 +120,7 @@ describe('Tutorial part 6', () => { element(by.buttonText('save')).click(); browser.waitForAngular(); // seems necessary to gets tests to pass for toh-pt6 - let targetHeroElt = getPageElts().topHeroes.get(targetHeroDashboardIndex); + const targetHeroElt = getPageElts().topHeroes.get(targetHeroDashboardIndex); expect(targetHeroElt.getText()).toEqual(newHeroName); }); @@ -132,7 +132,7 @@ describe('Tutorial part 6', () => { it('can switch to Heroes view', () => { getPageElts().appHeroesHref.click(); - let page = getPageElts(); + const page = getPageElts(); expect(page.appHeroes.isPresent()).toBeTruthy(); expect(page.allHeroes.count()).toEqual(10, 'number of heroes'); }); @@ -140,9 +140,9 @@ describe('Tutorial part 6', () => { it('can route to hero details', async () => { getHeroLiEltById(targetHero.id).click(); - let page = getPageElts(); + const page = getPageElts(); expect(page.heroDetail.isPresent()).toBeTruthy('shows hero detail'); - let hero = await Hero.fromDetail(page.heroDetail); + const hero = await Hero.fromDetail(page.heroDetail); expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(targetHero.name.toUpperCase()); }); @@ -152,7 +152,7 @@ describe('Tutorial part 6', () => { it(`shows ${newHeroName} in Heroes list`, () => { element(by.buttonText('save')).click(); browser.waitForAngular(); - let expectedText = `${targetHero.id} ${newHeroName}`; + const expectedText = `${targetHero.id} ${newHeroName}`; expect(getHeroAEltById(targetHero.id).getText()).toEqual(expectedText); }); @@ -179,8 +179,8 @@ describe('Tutorial part 6', () => { element(by.css('input')).sendKeys(addedHeroName); element(by.buttonText('add')).click(); - let page = getPageElts(); - let heroesAfter = await toHeroArray(page.allHeroes); + const page = getPageElts(); + const heroesAfter = await toHeroArray(page.allHeroes); expect(heroesAfter.length).toEqual(numHeroes + 1, 'number of heroes'); expect(heroesAfter.slice(0, numHeroes)).toEqual(heroesBefore, 'Old heroes are still there'); @@ -233,34 +233,34 @@ describe('Tutorial part 6', () => { it(`continues search with 'e' and gets ${targetHero.name}`, async () => { getPageElts().searchBox.sendKeys('n'); browser.sleep(1000); - let page = getPageElts(); + const page = getPageElts(); expect(page.searchResults.count()).toBe(1); - let hero = page.searchResults.get(0); + const hero = page.searchResults.get(0); expect(hero.getText()).toEqual(targetHero.name); }); it(`navigates to ${targetHero.name} details view`, async () => { - let hero = getPageElts().searchResults.get(0); + const hero = getPageElts().searchResults.get(0); expect(hero.getText()).toEqual(targetHero.name); hero.click(); - let page = getPageElts(); + const page = getPageElts(); expect(page.heroDetail.isPresent()).toBeTruthy('shows hero detail'); - let hero2 = await Hero.fromDetail(page.heroDetail); + const hero2 = await Hero.fromDetail(page.heroDetail); expect(hero2.id).toEqual(targetHero.id); expect(hero2.name).toEqual(targetHero.name.toUpperCase()); }); }); async function dashboardSelectTargetHero() { - let targetHeroElt = getPageElts().topHeroes.get(targetHeroDashboardIndex); + const targetHeroElt = getPageElts().topHeroes.get(targetHeroDashboardIndex); expect(targetHeroElt.getText()).toEqual(targetHero.name); targetHeroElt.click(); browser.waitForAngular(); // seems necessary to gets tests to pass for toh-pt6 - let page = getPageElts(); + const page = getPageElts(); expect(page.heroDetail.isPresent()).toBeTruthy('shows hero detail'); - let hero = await Hero.fromDetail(page.heroDetail); + const hero = await Hero.fromDetail(page.heroDetail); expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(targetHero.name.toUpperCase()); } @@ -269,8 +269,8 @@ describe('Tutorial part 6', () => { // Assumes that the current view is the hero details view. addToHeroName(nameSuffix); - let page = getPageElts(); - let hero = await Hero.fromDetail(page.heroDetail); + const page = getPageElts(); + const hero = await Hero.fromDetail(page.heroDetail); expect(hero.id).toEqual(targetHero.id); expect(hero.name).toEqual(newHeroName.toUpperCase()); } @@ -278,28 +278,28 @@ describe('Tutorial part 6', () => { }); function addToHeroName(text: string): promise.Promise { - let input = element(by.css('input')); + const input = element(by.css('input')); return input.sendKeys(text); } function expectHeading(hLevel: number, expectedText: string): void { - let hTag = `h${hLevel}`; - let hText = element(by.css(hTag)).getText(); + const hTag = `h${hLevel}`; + const hText = element(by.css(hTag)).getText(); expect(hText).toEqual(expectedText, hTag); } function getHeroAEltById(id: number): ElementFinder { - let spanForId = element(by.cssContainingText('li span.badge', id.toString())); + const spanForId = element(by.cssContainingText('li span.badge', id.toString())); return spanForId.element(by.xpath('..')); } function getHeroLiEltById(id: number): ElementFinder { - let spanForId = element(by.cssContainingText('li span.badge', id.toString())); + const spanForId = element(by.cssContainingText('li span.badge', id.toString())); return spanForId.element(by.xpath('../..')); } async function toHeroArray(allHeroes: ElementArrayFinder): Promise { - let promisedHeroes = await allHeroes.map(Hero.fromLi); + const promisedHeroes = await allHeroes.map(Hero.fromLi); // The cast is necessary to get around issuing with the signature of Promise.all() return Promise.all(promisedHeroes) as Promise; } diff --git a/aio/content/examples/two-way-binding/e2e/src/app.e2e-spec.ts b/aio/content/examples/two-way-binding/e2e/src/app.e2e-spec.ts index 73a4ecce33..229a0987d3 100644 --- a/aio/content/examples/two-way-binding/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/two-way-binding/e2e/src/app.e2e-spec.ts @@ -6,10 +6,10 @@ describe('Two-way binding e2e tests', () => { browser.get(''); }); - let minusButton = element.all(by.css('button')).get(0); - let plusButton = element.all(by.css('button')).get(1); - let minus2Button = element.all(by.css('button')).get(2); - let plus2Button = element.all(by.css('button')).get(3); + const minusButton = element.all(by.css('button')).get(0); + const plusButton = element.all(by.css('button')).get(1); + const minus2Button = element.all(by.css('button')).get(2); + const plus2Button = element.all(by.css('button')).get(3); it('should display Two-way Binding', () => { expect(element(by.css('h1')).getText()).toEqual('Two-way Binding'); diff --git a/aio/content/examples/upgrade-lazy-load-ajs/e2e/src/app.e2e-spec.ts b/aio/content/examples/upgrade-lazy-load-ajs/e2e/src/app.e2e-spec.ts index 02e46869e0..b8999370cc 100644 --- a/aio/content/examples/upgrade-lazy-load-ajs/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/upgrade-lazy-load-ajs/e2e/src/app.e2e-spec.ts @@ -57,7 +57,7 @@ describe('Lazy Loading AngularJS Tests', () => { // Run the protractor pre-bootstrap logic and resumeBootstrap // Based on https://github.com/angular/protractor/blob/5.3.0/lib/browser.ts#L950-L969 { - let moduleNames = []; + const moduleNames = []; for (const {name, script, args} of browser.mockModules_) { moduleNames.push(name); await browser.executeScriptWithDescription(script, 'add mock module ' + name, ...args); diff --git a/aio/content/examples/upgrade-phonecat-1-typescript/app/core/phone/phone.service.spec.ts b/aio/content/examples/upgrade-phonecat-1-typescript/app/core/phone/phone.service.spec.ts index 0339bf4a50..1b01396baa 100644 --- a/aio/content/examples/upgrade-phonecat-1-typescript/app/core/phone/phone.service.spec.ts +++ b/aio/content/examples/upgrade-phonecat-1-typescript/app/core/phone/phone.service.spec.ts @@ -2,7 +2,7 @@ describe('Phone', () => { let $httpBackend: angular.IHttpBackendService; let Phone: any; - let phonesData = [ + const phonesData = [ {name: 'Phone X'}, {name: 'Phone Y'}, {name: 'Phone Z'} @@ -31,7 +31,7 @@ describe('Phone', () => { }); it('should fetch the phones data from `/phones/phones.json`', () => { - let phones = Phone.query(); + const phones = Phone.query(); expect(phones).toEqual([]); diff --git a/aio/content/examples/upgrade-phonecat-1-typescript/app/phone-detail/phone-detail.component.spec.ts b/aio/content/examples/upgrade-phonecat-1-typescript/app/phone-detail/phone-detail.component.spec.ts index 38a3ecfcef..cf90ac574c 100644 --- a/aio/content/examples/upgrade-phonecat-1-typescript/app/phone-detail/phone-detail.component.spec.ts +++ b/aio/content/examples/upgrade-phonecat-1-typescript/app/phone-detail/phone-detail.component.spec.ts @@ -9,7 +9,7 @@ describe('phoneDetail', () => { describe('PhoneDetailController', () => { let $httpBackend: angular.IHttpBackendService; let ctrl: any; - let xyzPhoneData = { + const xyzPhoneData = { name: 'phone xyz', images: ['image/url1.png', 'image/url2.png'] }; diff --git a/aio/content/examples/upgrade-phonecat-1-typescript/app/phone-detail/phone-detail.component.ts b/aio/content/examples/upgrade-phonecat-1-typescript/app/phone-detail/phone-detail.component.ts index 353eb08e99..bd971028bd 100644 --- a/aio/content/examples/upgrade-phonecat-1-typescript/app/phone-detail/phone-detail.component.ts +++ b/aio/content/examples/upgrade-phonecat-1-typescript/app/phone-detail/phone-detail.component.ts @@ -6,7 +6,7 @@ class PhoneDetailController { static $inject = ['$routeParams', 'Phone']; constructor($routeParams: angular.route.IRouteParamsService, Phone: any) { - let phoneId = $routeParams.phoneId; + const phoneId = $routeParams.phoneId; this.phone = Phone.get({phoneId}, (phone: any) => { this.setImage(phone.images[0]); }); diff --git a/aio/content/examples/upgrade-phonecat-1-typescript/e2e-spec.ts b/aio/content/examples/upgrade-phonecat-1-typescript/e2e-spec.ts index 77aa387566..fe87205fcd 100644 --- a/aio/content/examples/upgrade-phonecat-1-typescript/e2e-spec.ts +++ b/aio/content/examples/upgrade-phonecat-1-typescript/e2e-spec.ts @@ -29,8 +29,8 @@ describe('PhoneCat Application', () => { }); it('should filter the phone list as a user types into the search box', () => { - let phoneList = element.all(by.repeater('phone in $ctrl.phones')); - let query = element(by.model('$ctrl.query')); + const phoneList = element.all(by.repeater('phone in $ctrl.phones')); + const query = element(by.model('$ctrl.query')); waitForCount(phoneList, 20); expect(phoneList.count()).toBe(20); @@ -46,10 +46,10 @@ describe('PhoneCat Application', () => { }); it('should be possible to control phone order via the drop-down menu', () => { - let queryField = element(by.model('$ctrl.query')); - let orderSelect = element(by.model('$ctrl.orderProp')); - let nameOption = orderSelect.element(by.css('option[value="name"]')); - let phoneNameColumn = element.all(by.repeater('phone in $ctrl.phones').column('phone.name')); + const queryField = element(by.model('$ctrl.query')); + const orderSelect = element(by.model('$ctrl.orderProp')); + const nameOption = orderSelect.element(by.css('option[value="name"]')); + const phoneNameColumn = element.all(by.repeater('phone in $ctrl.phones').column('phone.name')); function getNames() { return phoneNameColumn.map((elem: ElementFinder) => elem.getText()); @@ -72,14 +72,14 @@ describe('PhoneCat Application', () => { }); it('should render phone specific links', () => { - let phoneList = element.all(by.repeater('phone in $ctrl.phones')); - let query = element(by.model('$ctrl.query')); + const phoneList = element.all(by.repeater('phone in $ctrl.phones')); + const query = element(by.model('$ctrl.query')); query.sendKeys('nexus'); waitForCount(phoneList, 1); - let nexusPhone = phoneList.first(); - let detailLink = nexusPhone.all(by.css('a')).first(); + const nexusPhone = phoneList.first(); + const detailLink = nexusPhone.all(by.css('a')).first(); detailLink.click(); expect(browser.getLocationAbsUrl()).toBe('/phones/nexus-s'); @@ -98,14 +98,14 @@ describe('PhoneCat Application', () => { }); it('should display the first phone image as the main phone image', () => { - let mainImage = element(by.css('img.phone.selected')); + const mainImage = element(by.css('img.phone.selected')); expect(mainImage.getAttribute('src')).toMatch(/img\/phones\/nexus-s.0.jpg/); }); it('should swap the main image when clicking on a thumbnail image', () => { - let mainImage = element(by.css('img.phone.selected')); - let thumbnails = element.all(by.css('.phone-thumbs img')); + const mainImage = element(by.css('img.phone.selected')); + const thumbnails = element.all(by.css('.phone-thumbs img')); thumbnails.get(2).click(); expect(mainImage.getAttribute('src')).toMatch(/img\/phones\/nexus-s.2.jpg/); diff --git a/aio/content/examples/upgrade-phonecat-2-hybrid/app/core/phone/phone.service.spec.ts b/aio/content/examples/upgrade-phonecat-2-hybrid/app/core/phone/phone.service.spec.ts index 96f719f834..32f83a6721 100644 --- a/aio/content/examples/upgrade-phonecat-2-hybrid/app/core/phone/phone.service.spec.ts +++ b/aio/content/examples/upgrade-phonecat-2-hybrid/app/core/phone/phone.service.spec.ts @@ -6,7 +6,7 @@ import { Phone, PhoneData } from './phone.service'; describe('Phone', () => { let phone: Phone; - let phonesData: PhoneData[] = [ + const phonesData: PhoneData[] = [ {name: 'Phone X', snippet: '', images: []}, {name: 'Phone Y', snippet: '', images: []}, {name: 'Phone Z', snippet: '', images: []} diff --git a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.ajs.ts b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.ajs.ts index e48cf0ef0e..5d4c141599 100644 --- a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.ajs.ts +++ b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.ajs.ts @@ -9,7 +9,7 @@ class PhoneDetailController { static $inject = ['$routeParams', 'phone']; constructor($routeParams: angular.route.IRouteParamsService, phone: Phone) { - let phoneId = $routeParams.phoneId; + const phoneId = $routeParams.phoneId; phone.get(phoneId).subscribe(data => { this.phone = data; this.setImage(data.images[0]); diff --git a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.spec.ts b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.spec.ts index 10e25cd264..607fad3184 100644 --- a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.spec.ts +++ b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-detail/phone-detail.component.spec.ts @@ -52,7 +52,7 @@ describe('PhoneDetailComponent', () => { it('should fetch phone detail', () => { const fixture = TestBed.createComponent(PhoneDetailComponent); fixture.detectChanges(); - let compiled = fixture.debugElement.nativeElement; + const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('h1').textContent).toContain(xyzPhoneData().name); }); diff --git a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.ts b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.ts index 453df46d25..903b46a6d6 100644 --- a/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.ts +++ b/aio/content/examples/upgrade-phonecat-2-hybrid/app/phone-list/phone-list.component.ts @@ -35,8 +35,8 @@ export class PhoneListComponent { private filterPhones(phones: PhoneData[]) { if (phones && this.query) { return phones.filter(phone => { - let name = phone.name.toLowerCase(); - let snippet = phone.snippet.toLowerCase(); + const name = phone.name.toLowerCase(); + const snippet = phone.snippet.toLowerCase(); return name.indexOf(this.query) >= 0 || snippet.indexOf(this.query) >= 0; }); } diff --git a/aio/content/examples/upgrade-phonecat-2-hybrid/e2e-spec.ts b/aio/content/examples/upgrade-phonecat-2-hybrid/e2e-spec.ts index ca5d1fda8a..6c09547b39 100644 --- a/aio/content/examples/upgrade-phonecat-2-hybrid/e2e-spec.ts +++ b/aio/content/examples/upgrade-phonecat-2-hybrid/e2e-spec.ts @@ -18,8 +18,8 @@ describe('PhoneCat Application', () => { }); it('should filter the phone list as a user types into the search box', () => { - let phoneList = element.all(by.css('.phones li')); - let query = element(by.css('input')); + const phoneList = element.all(by.css('.phones li')); + const query = element(by.css('input')); expect(phoneList.count()).toBe(20); @@ -32,10 +32,10 @@ describe('PhoneCat Application', () => { }); it('should be possible to control phone order via the drop-down menu', () => { - let queryField = element(by.css('input')); - let orderSelect = element(by.css('select')); - let nameOption = orderSelect.element(by.css('option[value="name"]')); - let phoneNameColumn = element.all(by.css('.phones .name')); + const queryField = element(by.css('input')); + const orderSelect = element(by.css('select')); + const nameOption = orderSelect.element(by.css('option[value="name"]')); + const phoneNameColumn = element.all(by.css('.phones .name')); function getNames() { return phoneNameColumn.map((elem) => elem.getText()); @@ -57,7 +57,7 @@ describe('PhoneCat Application', () => { }); it('should render phone specific links', () => { - let query = element(by.css('input')); + const query = element(by.css('input')); query.sendKeys('nexus'); element.all(by.css('.phones li a')).first().click(); @@ -78,14 +78,14 @@ describe('PhoneCat Application', () => { }); it('should display the first phone image as the main phone image', () => { - let mainImage = element(by.css('img.phone.selected')); + const mainImage = element(by.css('img.phone.selected')); expect(mainImage.getAttribute('src')).toMatch(/img\/phones\/nexus-s.0.jpg/); }); it('should swap the main image when clicking on a thumbnail image', () => { - let mainImage = element(by.css('img.phone.selected')); - let thumbnails = element.all(by.css('.phone-thumbs img')); + const mainImage = element(by.css('img.phone.selected')); + const thumbnails = element.all(by.css('.phone-thumbs img')); thumbnails.get(2).click(); expect(mainImage.getAttribute('src')).toMatch(/img\/phones\/nexus-s.2.jpg/); diff --git a/aio/content/examples/upgrade-phonecat-3-final/app/core/phone/phone.service.spec.ts b/aio/content/examples/upgrade-phonecat-3-final/app/core/phone/phone.service.spec.ts index f6c79d5591..bfc0e890ab 100644 --- a/aio/content/examples/upgrade-phonecat-3-final/app/core/phone/phone.service.spec.ts +++ b/aio/content/examples/upgrade-phonecat-3-final/app/core/phone/phone.service.spec.ts @@ -5,7 +5,7 @@ import { Phone, PhoneData } from './phone.service'; describe('Phone', () => { let phone: Phone; - let phonesData: PhoneData[] = [ + const phonesData: PhoneData[] = [ {name: 'Phone X', snippet: '', images: []}, {name: 'Phone Y', snippet: '', images: []}, {name: 'Phone Z', snippet: '', images: []} diff --git a/aio/content/examples/upgrade-phonecat-3-final/app/phone-detail/phone-detail.component.spec.ts b/aio/content/examples/upgrade-phonecat-3-final/app/phone-detail/phone-detail.component.spec.ts index 10e25cd264..607fad3184 100644 --- a/aio/content/examples/upgrade-phonecat-3-final/app/phone-detail/phone-detail.component.spec.ts +++ b/aio/content/examples/upgrade-phonecat-3-final/app/phone-detail/phone-detail.component.spec.ts @@ -52,7 +52,7 @@ describe('PhoneDetailComponent', () => { it('should fetch phone detail', () => { const fixture = TestBed.createComponent(PhoneDetailComponent); fixture.detectChanges(); - let compiled = fixture.debugElement.nativeElement; + const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('h1').textContent).toContain(xyzPhoneData().name); }); diff --git a/aio/content/examples/upgrade-phonecat-3-final/app/phone-list/phone-list.component.ts b/aio/content/examples/upgrade-phonecat-3-final/app/phone-list/phone-list.component.ts index 6cfd172027..a9268269ea 100644 --- a/aio/content/examples/upgrade-phonecat-3-final/app/phone-list/phone-list.component.ts +++ b/aio/content/examples/upgrade-phonecat-3-final/app/phone-list/phone-list.component.ts @@ -26,8 +26,8 @@ export class PhoneListComponent { private filterPhones(phones: PhoneData[]) { if (phones && this.query) { return phones.filter(phone => { - let name = phone.name.toLowerCase(); - let snippet = phone.snippet.toLowerCase(); + const name = phone.name.toLowerCase(); + const snippet = phone.snippet.toLowerCase(); return name.indexOf(this.query) >= 0 || snippet.indexOf(this.query) >= 0; }); } diff --git a/aio/content/examples/upgrade-phonecat-3-final/e2e-spec.ts b/aio/content/examples/upgrade-phonecat-3-final/e2e-spec.ts index 5ef6d7f77d..882e38a55b 100644 --- a/aio/content/examples/upgrade-phonecat-3-final/e2e-spec.ts +++ b/aio/content/examples/upgrade-phonecat-3-final/e2e-spec.ts @@ -22,8 +22,8 @@ describe('PhoneCat Application', () => { }); it('should filter the phone list as a user types into the search box', () => { - let phoneList = element.all(by.css('.phones li')); - let query = element(by.css('input')); + const phoneList = element.all(by.css('.phones li')); + const query = element(by.css('input')); expect(phoneList.count()).toBe(20); @@ -36,10 +36,10 @@ describe('PhoneCat Application', () => { }); it('should be possible to control phone order via the drop-down menu', () => { - let queryField = element(by.css('input')); - let orderSelect = element(by.css('select')); - let nameOption = orderSelect.element(by.css('option[value="name"]')); - let phoneNameColumn = element.all(by.css('.phones .name')); + const queryField = element(by.css('input')); + const orderSelect = element(by.css('select')); + const nameOption = orderSelect.element(by.css('option[value="name"]')); + const phoneNameColumn = element.all(by.css('.phones .name')); function getNames() { return phoneNameColumn.map((elem) => elem.getText()); @@ -62,7 +62,7 @@ describe('PhoneCat Application', () => { // #docregion links it('should render phone specific links', () => { - let query = element(by.css('input')); + const query = element(by.css('input')); query.sendKeys('nexus'); element.all(by.css('.phones li a')).first().click(); browser.getCurrentUrl().then((url: string) => { @@ -84,14 +84,14 @@ describe('PhoneCat Application', () => { }); it('should display the first phone image as the main phone image', () => { - let mainImage = element(by.css('img.phone.selected')); + const mainImage = element(by.css('img.phone.selected')); expect(mainImage.getAttribute('src')).toMatch(/img\/phones\/nexus-s.0.jpg/); }); it('should swap the main image when clicking on a thumbnail image', () => { - let mainImage = element(by.css('img.phone.selected')); - let thumbnails = element.all(by.css('.phone-thumbs img')); + const mainImage = element(by.css('img.phone.selected')); + const thumbnails = element.all(by.css('.phone-thumbs img')); thumbnails.get(2).click(); expect(mainImage.getAttribute('src')).toMatch(/img\/phones\/nexus-s.2.jpg/); diff --git a/aio/content/examples/user-input/e2e/src/app.e2e-spec.ts b/aio/content/examples/user-input/e2e/src/app.e2e-spec.ts index b6c78dd921..02948e6bb5 100644 --- a/aio/content/examples/user-input/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/user-input/e2e/src/app.e2e-spec.ts @@ -7,8 +7,8 @@ describe('User Input Tests', () => { }); it('should support the click event', () => { - let mainEle = element(by.css('app-click-me')); - let buttonEle = element(by.css('app-click-me button')); + const mainEle = element(by.css('app-click-me')); + const buttonEle = element(by.css('app-click-me button')); expect(mainEle.getText()).not.toContain('You are my hero!'); buttonEle.click().then(() => { expect(mainEle.getText()).toContain('You are my hero!'); @@ -16,8 +16,8 @@ describe('User Input Tests', () => { }); it('should support the click event with an event payload', () => { - let mainEle = element(by.css('app-click-me2')); - let buttonEle = element(by.css('app-click-me2 button')); + const mainEle = element(by.css('app-click-me2')); + const buttonEle = element(by.css('app-click-me2 button')); expect(mainEle.getText()).not.toContain('Event target is '); buttonEle.click().then(() => { expect(mainEle.getText()).toContain('Event target is BUTTON'); @@ -25,36 +25,36 @@ describe('User Input Tests', () => { }); it('should support the keyup event ', () => { - let mainEle = element(by.css('app-key-up1')); - let inputEle = mainEle.element(by.css('input')); - let outputTextEle = mainEle.element(by.css('p')); + const mainEle = element(by.css('app-key-up1')); + const inputEle = mainEle.element(by.css('input')); + const outputTextEle = mainEle.element(by.css('p')); expect(outputTextEle.getText()).toEqual(''); inputEle.sendKeys('abc'); expect(outputTextEle.getText()).toEqual('a | ab | abc |'); }); it('should support user input from a local template let (loopback)', () => { - let mainEle = element(by.css('app-loop-back')); - let inputEle = mainEle.element(by.css('input')); - let outputTextEle = mainEle.element(by.css('p')); + const mainEle = element(by.css('app-loop-back')); + const inputEle = mainEle.element(by.css('input')); + const outputTextEle = mainEle.element(by.css('p')); expect(outputTextEle.getText()).toEqual(''); inputEle.sendKeys('abc'); expect(outputTextEle.getText()).toEqual('abc'); }); it('should be able to combine click event with a local template var', () => { - let mainEle = element(by.css('app-key-up2')); - let inputEle = mainEle.element(by.css('input')); - let outputTextEle = mainEle.element(by.css('p')); + const mainEle = element(by.css('app-key-up2')); + const inputEle = mainEle.element(by.css('input')); + const outputTextEle = mainEle.element(by.css('p')); expect(outputTextEle.getText()).toEqual(''); inputEle.sendKeys('abc'); expect(outputTextEle.getText()).toEqual('a | ab | abc |'); }); it('should be able to filter key events', () => { - let mainEle = element(by.css('app-key-up3')); - let inputEle = mainEle.element(by.css('input')); - let outputTextEle = mainEle.element(by.css('p')); + const mainEle = element(by.css('app-key-up3')); + const inputEle = mainEle.element(by.css('input')); + const outputTextEle = mainEle.element(by.css('p')); expect(outputTextEle.getText()).toEqual(''); inputEle.sendKeys('abc'); expect(outputTextEle.getText()).toEqual('', 'should be blank - have not sent enter yet'); @@ -64,10 +64,10 @@ describe('User Input Tests', () => { }); it('should be able to filter blur events', () => { - let prevInputEle = element(by.css('app-key-up3 input')); - let mainEle = element(by.css('app-key-up4')); - let inputEle = mainEle.element(by.css('input')); - let outputTextEle = mainEle.element(by.css('p')); + const prevInputEle = element(by.css('app-key-up3 input')); + const mainEle = element(by.css('app-key-up4')); + const inputEle = mainEle.element(by.css('input')); + const outputTextEle = mainEle.element(by.css('p')); expect(outputTextEle.getText()).toEqual(''); inputEle.sendKeys('abc'); expect(outputTextEle.getText()).toEqual('', 'should be blank - have not sent enter yet'); @@ -78,10 +78,10 @@ describe('User Input Tests', () => { }); it('should be able to compose little tour of heroes', () => { - let mainEle = element(by.css('app-little-tour')); - let inputEle = mainEle.element(by.css('input')); - let addButtonEle = mainEle.element(by.css('button')); - let heroEles = mainEle.all(by.css('li')); + const mainEle = element(by.css('app-little-tour')); + const inputEle = mainEle.element(by.css('input')); + const addButtonEle = mainEle.element(by.css('button')); + const heroEles = mainEle.all(by.css('li')); let numHeroes: number; expect(heroEles.count()).toBeGreaterThan(0); heroEles.count().then((count: number) => { diff --git a/aio/content/examples/user-input/src/app/click-me2.component.ts b/aio/content/examples/user-input/src/app/click-me2.component.ts index 476d5db969..421de8d8e3 100644 --- a/aio/content/examples/user-input/src/app/click-me2.component.ts +++ b/aio/content/examples/user-input/src/app/click-me2.component.ts @@ -12,7 +12,7 @@ export class ClickMe2Component { clicks = 1; onClickMe2(event: any) { - let evtMsg = event ? ' Event target is ' + event.target.tagName : ''; + const evtMsg = event ? ' Event target is ' + event.target.tagName : ''; this.clickMessage = (`Click #${this.clicks++}. ${evtMsg}`); } } diff --git a/aio/content/guide/comparing-observables.md b/aio/content/guide/comparing-observables.md index c3402b1644..7dd191ba95 100644 --- a/aio/content/guide/comparing-observables.md +++ b/aio/content/guide/comparing-observables.md @@ -21,16 +21,16 @@ Observables are often compared to promises. Here are some key differences: * Observables are not executed until a consumer subscribes. The `subscribe()` executes the defined behavior once, and it can be called again. Each subscription has its own computation. Resubscription causes recomputation of values. - * Promises execute immediately, and just once. The computation of the result is initiated when the promise is created. There is no way to restart work. All `then` clauses (subscriptions) share the same computation. - @@ -39,17 +39,17 @@ Observables are often compared to promises. Here are some key differences: * Observables differentiate between transformation function such as a map and subscription. Only subscription activates the subscriber function to start computing the values. - * Promises do not differentiate between the last `.then` clauses (equivalent to subscription) and intermediate `.then` clauses (equivalent to map). - @@ -57,9 +57,9 @@ Observables are often compared to promises. Here are some key differences: * Observable subscriptions are cancellable. Unsubscribing removes the listener from receiving further values, and notifies the subscriber function to cancel work. - @@ -69,16 +69,16 @@ Observables are often compared to promises. Here are some key differences: * Observable execution errors are delivered to the subscriber's error handler, and the subscriber automatically unsubscribes from the observable. - * Promises push errors to the child promises. - @@ -157,9 +157,9 @@ Here are some code samples that illustrate how the same kind of operation is def Creation & cancellation
    // Setup
    -let clicks$ = fromEvent(buttonEl, ‘click’);
    +const clicks$ = fromEvent(buttonEl, ‘click’);
     // Begin listening
    -let subscription = clicks$
    +const subscription = clicks$
       .subscribe(e => console.log(‘Clicked’, e))
     // Stop listening
     subscription.unsubscribe();
    diff --git a/aio/content/guide/http.md b/aio/content/guide/http.md index 3605a9d871..f5d3cf009e 100644 --- a/aio/content/guide/http.md +++ b/aio/content/guide/http.md @@ -273,7 +273,7 @@ In the following example, the `searchHeroes()` method uses a JSONP request to qu searchHeroes(term: string): Observable { term = term.trim(); - let heroesURL = `${this.heroesURL}?${term}`; + const heroesURL = `${this.heroesURL}?${term}`; return this.http.jsonp(heroesUrl, 'callback').pipe( catchError(this.handleError('searchHeroes', [])) // then handle the error ); diff --git a/aio/content/guide/router.md b/aio/content/guide/router.md index 82a711e0a3..abf916b369 100644 --- a/aio/content/guide/router.md +++ b/aio/content/guide/router.md @@ -335,22 +335,22 @@ Inject `ActivatedRoute` and `Router` in the constructor of the component class s - item$: Observable; + hero$: Observable; constructor( private route: ActivatedRoute, private router: Router ) {} ngOnInit() { - let id = this.route.snapshot.paramMap.get('id'); - this.hero$ = this.service.getHero(id); + const heroId = this.route.snapshot.paramMap.get('id'); + this.hero$ = this.service.getHero(heroId); } - gotoItems(item: Item) { - let heroId = item ? hero.id : null; - // Pass along the item id if available + gotoItems(hero: Hero) { + const heroId = hero ? hero.id : null; + // Pass along the hero id if available // so that the HeroList component can select that item. - this.router.navigate(['/heroes', { id: itemId }]); + this.router.navigate(['/heroes', { id: heroId }]); }