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:

committed by
Alex Rickabaugh

parent
07a003352d
commit
01db37435f
@ -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,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<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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user