refactor(docs-infra): fix docs examples for tslint rules related to object properties (#38143)

This commit updates the docs examples to be compatible with the
`no-string-literal`, `object-literal-key-quotes` and
`object-literal-shorthand` tslint rules.

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:14 +03:00
committed by Alex Rickabaugh
parent d4a723a464
commit ff72da60d3
44 changed files with 78 additions and 88 deletions

View File

@ -9,7 +9,7 @@ describe('Testing Example', () => {
let navElts = element.all(by.css('app-root nav a'));
return {
navElts: navElts,
navElts,
appDashboard: element(by.css('app-root app-dashboard')),
};

View File

@ -222,7 +222,7 @@ describe('demo (with TestBed):', () => {
fixture.detectChanges();
const ngForRow = fixture.debugElement.query(By.directive(IoComponent)); // first hero ngForRow
const hero = ngForRow.context['hero']; // the hero object passed into the row
const hero = ngForRow.context.hero; // the hero object passed into the row
expect(hero.name).toBe(heroName, 'ngRow.context.hero');
const rowComp = ngForRow.componentInstance;
@ -514,11 +514,11 @@ describe('demo (with TestBed):', () => {
expect(comp.children.toArray().length).toBe(4,
'three different child components and an ElementRef with #content');
expect(el.references['nc']).toBe(comp, '#nc reference to component');
expect(el.references.nc).toBe(comp, '#nc reference to component');
// #docregion custom-predicate
// Filter for DebugElements with a #content reference
const contentRefs = el.queryAll( de => de.references['content']);
const contentRefs = el.queryAll( de => de.references.content);
// #enddocregion custom-predicate
expect(contentRefs.length).toBe(4, 'elements w/ a #content reference');
});

View File

@ -72,7 +72,7 @@ describe('HttpClient testing', () => {
// Make an HTTP GET request with specific header
httpClient.get<Data>(testUrl, {
headers: new HttpHeaders({'Authorization': 'my-auth-token'})
headers: new HttpHeaders({Authorization: 'my-auth-token'})
})
.subscribe(data =>
expect(data).toEqual(testData)

View File

@ -7,7 +7,7 @@ describe('CanvasComponent', () => {
// #enddocregion without-toBlob-macrotask
// #docregion enable-toBlob-macrotask
beforeEach(() => {
window['__zone_symbol__FakeAsyncTestMacroTask'] = [
(window as any).__zone_symbol__FakeAsyncTestMacroTask = [
{
source: 'HTMLCanvasElement.toBlob',
callbackArgs: [{ size: 200 }],

View File

@ -69,7 +69,7 @@ describe('HighlightDirective', () => {
it('bare <h2> should not have a customProperty', () => {
expect(bareH2.properties['customProperty']).toBeUndefined();
expect(bareH2.properties.customProperty).toBeUndefined();
});
// #enddocregion selected-tests

View File

@ -23,13 +23,13 @@ bootstrap();
//
function bootstrap () {
if (window['jasmineRef']) {
function bootstrap() {
if ((window as any).jasmineRef) {
location.reload();
return;
} else {
window.onload(undefined);
window['jasmineRef'] = jasmine.getEnv();
(window as any).jasmineRef = jasmine.getEnv();
}
// First, initialize the Angular testing environment.

View File

@ -1,3 +1,3 @@
import jasmineRequire from 'jasmine-core/lib/jasmine-core/jasmine.js';
window['jasmineRequire'] = jasmineRequire;
(window as any).jasmineRequire = jasmineRequire;

View File

@ -5,7 +5,7 @@
export function addMatchers(): void {
jasmine.addMatchers({
toHaveText: toHaveText
toHaveText
});
}