refactor(docs-infra): fix docs examples for tslint rule prefer-const (#38143)

This commit updates the docs examples to be compatible with the
`prefer-const` tslint rule.

This is in preparation of updating the docs examples `tslint.json` to
match the one generated for new Angular CLI apps in a future commit.

PR Close #38143
This commit is contained in:
George Kalpakas
2020-07-30 13:03:19 +03:00
committed by Alex Rickabaugh
parent 07a003352d
commit 01db37435f
112 changed files with 601 additions and 601 deletions

View File

@ -24,9 +24,9 @@ class Hero {
// Get hero id and name from the given detail element.
static async fromDetail(detail: ElementFinder): Promise<Hero> {
// Get hero id from the first <div>
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<void> {
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);
}