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:
parent
fc709423f2
commit
8aa29438ac
|
@ -34,7 +34,7 @@ export class AppComponent {
|
||||||
|
|
||||||
// #docregion prepare-router-outlet
|
// #docregion prepare-router-outlet
|
||||||
prepareRoute(outlet: RouterOutlet) {
|
prepareRoute(outlet: RouterOutlet) {
|
||||||
return outlet && outlet.activatedRouteData && outlet.activatedRouteData['animation'];
|
return outlet && outlet.activatedRouteData && outlet.activatedRouteData.animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #enddocregion prepare-router-outlet
|
// #enddocregion prepare-router-outlet
|
||||||
|
|
|
@ -46,9 +46,9 @@ export class AppComponent implements OnInit {
|
||||||
setCurrentClasses() {
|
setCurrentClasses() {
|
||||||
// CSS classes: added/removed per current state of component properties
|
// CSS classes: added/removed per current state of component properties
|
||||||
this.currentClasses = {
|
this.currentClasses = {
|
||||||
'saveable': this.canSave,
|
saveable: this.canSave,
|
||||||
'modified': !this.isUnchanged,
|
modified: !this.isUnchanged,
|
||||||
'special': this.isSpecial
|
special: this.isSpecial
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// #enddocregion setClasses
|
// #enddocregion setClasses
|
||||||
|
@ -107,7 +107,7 @@ export class AppComponent implements OnInit {
|
||||||
trackByItems(index: number, item: Item): number { return item.id; }
|
trackByItems(index: number, item: Item): number { return item.id; }
|
||||||
// #enddocregion trackByItems
|
// #enddocregion trackByItems
|
||||||
|
|
||||||
trackById(index: number, item: any): number { return item['id']; }
|
trackById(index: number, item: any): number { return item.id; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,8 +111,8 @@ describe('Component Communication Cookbook Tests', () => {
|
||||||
let logs = ul.all(by.tagName('li'));
|
let logs = ul.all(by.tagName('li'));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
label: label,
|
label,
|
||||||
logs: logs,
|
logs,
|
||||||
count: logs.count()
|
count: logs.count()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,6 @@ if (!/e2e/.test(location.search)) {
|
||||||
],
|
],
|
||||||
declarations: directives,
|
declarations: directives,
|
||||||
bootstrap: [ AppComponent ],
|
bootstrap: [ AppComponent ],
|
||||||
schemas: schemas
|
schemas
|
||||||
})
|
})
|
||||||
export class AppModule { }
|
export class AppModule { }
|
||||||
|
|
|
@ -18,7 +18,7 @@ const template = '{{log}}';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'provider-1',
|
selector: 'provider-1',
|
||||||
template: template,
|
template,
|
||||||
// #docregion providers-1, providers-logger
|
// #docregion providers-1, providers-logger
|
||||||
providers: [Logger]
|
providers: [Logger]
|
||||||
// #enddocregion providers-1, providers-logger
|
// #enddocregion providers-1, providers-logger
|
||||||
|
@ -35,7 +35,7 @@ export class Provider1Component {
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'provider-3',
|
selector: 'provider-3',
|
||||||
template: template,
|
template,
|
||||||
providers:
|
providers:
|
||||||
// #docregion providers-3
|
// #docregion providers-3
|
||||||
[{ provide: Logger, useClass: Logger }]
|
[{ provide: Logger, useClass: Logger }]
|
||||||
|
@ -54,7 +54,7 @@ export class BetterLogger extends Logger {}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'provider-4',
|
selector: 'provider-4',
|
||||||
template: template,
|
template,
|
||||||
providers:
|
providers:
|
||||||
// #docregion providers-4
|
// #docregion providers-4
|
||||||
[{ provide: Logger, useClass: BetterLogger }]
|
[{ provide: Logger, useClass: BetterLogger }]
|
||||||
|
@ -84,7 +84,7 @@ export class EvenBetterLogger extends Logger {
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'provider-5',
|
selector: 'provider-5',
|
||||||
template: template,
|
template,
|
||||||
providers:
|
providers:
|
||||||
// #docregion providers-5
|
// #docregion providers-5
|
||||||
[ UserService,
|
[ UserService,
|
||||||
|
@ -112,7 +112,7 @@ export class OldLogger {
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'provider-6a',
|
selector: 'provider-6a',
|
||||||
template: template,
|
template,
|
||||||
providers:
|
providers:
|
||||||
// #docregion providers-6a
|
// #docregion providers-6a
|
||||||
[ NewLogger,
|
[ NewLogger,
|
||||||
|
@ -135,7 +135,7 @@ export class Provider6aComponent {
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'provider-6b',
|
selector: 'provider-6b',
|
||||||
template: template,
|
template,
|
||||||
providers:
|
providers:
|
||||||
// #docregion providers-6b
|
// #docregion providers-6b
|
||||||
[ NewLogger,
|
[ NewLogger,
|
||||||
|
@ -168,7 +168,7 @@ export const SilentLogger = {
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'provider-7',
|
selector: 'provider-7',
|
||||||
template: template,
|
template,
|
||||||
providers:
|
providers:
|
||||||
// #docregion providers-7
|
// #docregion providers-7
|
||||||
[{ provide: Logger, useValue: SilentLogger }]
|
[{ provide: Logger, useValue: SilentLogger }]
|
||||||
|
@ -186,7 +186,7 @@ export class Provider7Component {
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'provider-8',
|
selector: 'provider-8',
|
||||||
template: template,
|
template,
|
||||||
providers: [heroServiceProvider, Logger, UserService]
|
providers: [heroServiceProvider, Logger, UserService]
|
||||||
})
|
})
|
||||||
export class Provider8Component {
|
export class Provider8Component {
|
||||||
|
@ -202,7 +202,7 @@ export class Provider8Component {
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'provider-9',
|
selector: 'provider-9',
|
||||||
template: template,
|
template,
|
||||||
/*
|
/*
|
||||||
// #docregion providers-9-interface
|
// #docregion providers-9-interface
|
||||||
// FAIL! Can't use interface as provider token
|
// FAIL! Can't use interface as provider token
|
||||||
|
@ -241,7 +241,7 @@ let some_message = 'Hello from the injected logger';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'provider-10',
|
selector: 'provider-10',
|
||||||
template: template,
|
template,
|
||||||
providers: [{ provide: Logger, useValue: null }]
|
providers: [{ provide: Logger, useValue: null }]
|
||||||
})
|
})
|
||||||
export class Provider10Component implements OnInit {
|
export class Provider10Component implements OnInit {
|
||||||
|
|
|
@ -10,13 +10,14 @@ export class QuestionBase<T> {
|
||||||
options: {key: string, value: string}[];
|
options: {key: string, value: string}[];
|
||||||
|
|
||||||
constructor(options: {
|
constructor(options: {
|
||||||
value?: T,
|
value?: T;
|
||||||
key?: string,
|
key?: string;
|
||||||
label?: string,
|
label?: string;
|
||||||
required?: boolean,
|
required?: boolean;
|
||||||
order?: number,
|
order?: number;
|
||||||
controlType?: string,
|
controlType?: string;
|
||||||
type?: string
|
type?: string;
|
||||||
|
options?: {key: string, value: string}[];
|
||||||
} = {}) {
|
} = {}) {
|
||||||
this.value = options.value;
|
this.value = options.value;
|
||||||
this.key = options.key || '';
|
this.key = options.key || '';
|
||||||
|
@ -25,5 +26,6 @@ export class QuestionBase<T> {
|
||||||
this.order = options.order === undefined ? 1 : options.order;
|
this.order = options.order === undefined ? 1 : options.order;
|
||||||
this.controlType = options.controlType || '';
|
this.controlType = options.controlType || '';
|
||||||
this.type = options.type || '';
|
this.type = options.type || '';
|
||||||
|
this.options = options.options || [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,4 @@ import { QuestionBase } from './question-base';
|
||||||
|
|
||||||
export class DropdownQuestion extends QuestionBase<string> {
|
export class DropdownQuestion extends QuestionBase<string> {
|
||||||
controlType = 'dropdown';
|
controlType = 'dropdown';
|
||||||
options: {key: string, value: string}[] = [];
|
|
||||||
|
|
||||||
constructor(options: {} = {}) {
|
|
||||||
super(options);
|
|
||||||
this.options = options['options'] || [];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,4 @@ import { QuestionBase } from './question-base';
|
||||||
|
|
||||||
export class TextboxQuestion extends QuestionBase<string> {
|
export class TextboxQuestion extends QuestionBase<string> {
|
||||||
controlType = 'textbox';
|
controlType = 'textbox';
|
||||||
type: string;
|
|
||||||
|
|
||||||
constructor(options: {} = {}) {
|
|
||||||
super(options);
|
|
||||||
this.type = options['type'] || '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ function getPage(sectionTag: string) {
|
||||||
let buttons = section.all(by.css('button'));
|
let buttons = section.all(by.css('button'));
|
||||||
|
|
||||||
page = {
|
page = {
|
||||||
section: section,
|
section,
|
||||||
form: section.element(by.css('form')),
|
form: section.element(by.css('form')),
|
||||||
title: section.element(by.css('h1')),
|
title: section.element(by.css('h1')),
|
||||||
nameInput: section.element(by.css('#name')),
|
nameInput: section.element(by.css('#name')),
|
||||||
|
|
|
@ -22,13 +22,13 @@ export class HeroFormReactiveComponent implements OnInit {
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
// #docregion custom-validator
|
// #docregion custom-validator
|
||||||
this.heroForm = new FormGroup({
|
this.heroForm = new FormGroup({
|
||||||
'name': new FormControl(this.hero.name, [
|
name: new FormControl(this.hero.name, [
|
||||||
Validators.required,
|
Validators.required,
|
||||||
Validators.minLength(4),
|
Validators.minLength(4),
|
||||||
forbiddenNameValidator(/bob/i) // <-- Here's how you pass in the custom validator.
|
forbiddenNameValidator(/bob/i) // <-- Here's how you pass in the custom validator.
|
||||||
]),
|
]),
|
||||||
'alterEgo': new FormControl(this.hero.alterEgo),
|
alterEgo: new FormControl(this.hero.alterEgo),
|
||||||
'power': new FormControl(this.hero.power, Validators.required)
|
power: new FormControl(this.hero.power, Validators.required)
|
||||||
});
|
});
|
||||||
// #enddocregion custom-validator
|
// #enddocregion custom-validator
|
||||||
|
|
||||||
|
|
|
@ -22,16 +22,16 @@ export class HeroFormReactiveComponent implements OnInit {
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
// #docregion async-validation
|
// #docregion async-validation
|
||||||
this.heroForm = new FormGroup({
|
this.heroForm = new FormGroup({
|
||||||
'name': new FormControl(this.hero.name, [
|
name: new FormControl(this.hero.name, [
|
||||||
Validators.required,
|
Validators.required,
|
||||||
Validators.minLength(4),
|
Validators.minLength(4),
|
||||||
forbiddenNameValidator(/bob/i)
|
forbiddenNameValidator(/bob/i)
|
||||||
]),
|
]),
|
||||||
'alterEgo': new FormControl(this.hero.alterEgo, {
|
alterEgo: new FormControl(this.hero.alterEgo, {
|
||||||
asyncValidators: [this.alterEgoValidator.validate.bind(this.alterEgoValidator)],
|
asyncValidators: [this.alterEgoValidator.validate.bind(this.alterEgoValidator)],
|
||||||
updateOn: 'blur'
|
updateOn: 'blur'
|
||||||
}),
|
}),
|
||||||
'power': new FormControl(this.hero.power, Validators.required)
|
power: new FormControl(this.hero.power, Validators.required)
|
||||||
});
|
});
|
||||||
// #enddocregion async-validation
|
// #enddocregion async-validation
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,16 +21,16 @@ export class HeroFormReactiveComponent implements OnInit {
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.heroForm = new FormGroup({
|
this.heroForm = new FormGroup({
|
||||||
'name': new FormControl(this.hero.name, [
|
name: new FormControl(this.hero.name, [
|
||||||
Validators.required,
|
Validators.required,
|
||||||
Validators.minLength(4),
|
Validators.minLength(4),
|
||||||
forbiddenNameValidator(/bob/i)
|
forbiddenNameValidator(/bob/i)
|
||||||
]),
|
]),
|
||||||
'alterEgo': new FormControl(this.hero.alterEgo, {
|
alterEgo: new FormControl(this.hero.alterEgo, {
|
||||||
asyncValidators: [this.alterEgoValidator.validate.bind(this.alterEgoValidator)],
|
asyncValidators: [this.alterEgoValidator.validate.bind(this.alterEgoValidator)],
|
||||||
updateOn: 'blur'
|
updateOn: 'blur'
|
||||||
}),
|
}),
|
||||||
'power': new FormControl(this.hero.power, Validators.required)
|
power: new FormControl(this.hero.power, Validators.required)
|
||||||
}, { validators: identityRevealedValidator }); // <-- add custom validator at the FormGroup level
|
}, { validators: identityRevealedValidator }); // <-- add custom validator at the FormGroup level
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { AbstractControl, NG_VALIDATORS, Validator, ValidatorFn, Validators } fr
|
||||||
export function forbiddenNameValidator(nameRe: RegExp): ValidatorFn {
|
export function forbiddenNameValidator(nameRe: RegExp): ValidatorFn {
|
||||||
return (control: AbstractControl): {[key: string]: any} | null => {
|
return (control: AbstractControl): {[key: string]: any} | null => {
|
||||||
const forbidden = nameRe.test(control.value);
|
const forbidden = nameRe.test(control.value);
|
||||||
return forbidden ? {'forbiddenName': {value: control.value}} : null;
|
return forbidden ? {forbiddenName: {value: control.value}} : null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// #enddocregion custom-validator
|
// #enddocregion custom-validator
|
||||||
|
|
|
@ -8,7 +8,7 @@ export const identityRevealedValidator: ValidatorFn = (control: FormGroup): Vali
|
||||||
const name = control.get('name');
|
const name = control.get('name');
|
||||||
const alterEgo = control.get('alterEgo');
|
const alterEgo = control.get('alterEgo');
|
||||||
|
|
||||||
return name && alterEgo && name.value === alterEgo.value ? { 'identityRevealed': true } : null;
|
return name && alterEgo && name.value === alterEgo.value ? { identityRevealed: true } : null;
|
||||||
};
|
};
|
||||||
// #enddocregion cross-validation-validator
|
// #enddocregion cross-validation-validator
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,9 @@ export class HeroFormComponent {
|
||||||
// Reveal in html:
|
// Reveal in html:
|
||||||
// Name via form.controls = {{showFormControls(heroForm)}}
|
// Name via form.controls = {{showFormControls(heroForm)}}
|
||||||
showFormControls(form: any) {
|
showFormControls(form: any) {
|
||||||
return form && form.controls['name'] &&
|
return form && form.controls.name &&
|
||||||
// #docregion form-controls
|
// #docregion form-controls
|
||||||
form.controls['name'].value; // Dr. IQ
|
form.controls.name.value; // Dr. IQ
|
||||||
// #enddocregion form-controls
|
// #enddocregion form-controls
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,8 @@ export class ConfigComponent {
|
||||||
this.configService.getConfig_1()
|
this.configService.getConfig_1()
|
||||||
// #docregion v1, v1_callback
|
// #docregion v1, v1_callback
|
||||||
.subscribe((data: Config) => this.config = {
|
.subscribe((data: Config) => this.config = {
|
||||||
heroesUrl: data['heroesUrl'],
|
heroesUrl: data.heroesUrl,
|
||||||
textfile: data['textfile']
|
textfile: data.textfile
|
||||||
});
|
});
|
||||||
// #enddocregion v1_callback
|
// #enddocregion v1_callback
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { HttpErrorHandler, HandleError } from '../http-error-handler.service';
|
||||||
const httpOptions = {
|
const httpOptions = {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': 'my-auth-token'
|
Authorization: 'my-auth-token'
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
// #enddocregion http-options
|
// #enddocregion http-options
|
||||||
|
|
|
@ -22,13 +22,13 @@ import './testing/http-client.spec.ts';
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|
||||||
//
|
//
|
||||||
function bootstrap () {
|
function bootstrap() {
|
||||||
if (window['jasmineRef']) {
|
if ((window as any).jasmineRef) {
|
||||||
location.reload();
|
location.reload();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
window.onload(undefined);
|
window.onload(undefined);
|
||||||
window['jasmineRef'] = jasmine.getEnv();
|
(window as any).jasmineRef = jasmine.getEnv();
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, initialize the Angular testing environment.
|
// First, initialize the Angular testing environment.
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
import jasmineRequire from 'jasmine-core/lib/jasmine-core/jasmine.js';
|
import jasmineRequire from 'jasmine-core/lib/jasmine-core/jasmine.js';
|
||||||
|
|
||||||
window['jasmineRequire'] = jasmineRequire;
|
(window as any).jasmineRequire = jasmineRequire;
|
||||||
|
|
|
@ -73,7 +73,7 @@ describe('HttpClient testing', () => {
|
||||||
|
|
||||||
// Make an HTTP GET request with specific header
|
// Make an HTTP GET request with specific header
|
||||||
httpClient.get<Data>(testUrl, {
|
httpClient.get<Data>(testUrl, {
|
||||||
headers: new HttpHeaders({'Authorization': 'my-auth-token'})
|
headers: new HttpHeaders({Authorization: 'my-auth-token'})
|
||||||
})
|
})
|
||||||
.subscribe(data =>
|
.subscribe(data =>
|
||||||
expect(data).toEqual(testData)
|
expect(data).toEqual(testData)
|
||||||
|
|
|
@ -31,7 +31,7 @@ export class MyCounterComponent implements OnChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
// A change to `counter` is the only change we care about
|
// A change to `counter` is the only change we care about
|
||||||
let chng = changes['counter'];
|
let chng = changes.counter;
|
||||||
let cur = chng.currentValue;
|
let cur = chng.currentValue;
|
||||||
let prev = JSON.stringify(chng.previousValue); // first time is {}; after is integer
|
let prev = JSON.stringify(chng.previousValue); // first time is {}; after is integer
|
||||||
this.changeLog.push(`counter: currentValue = ${cur}, previousValue = ${prev}`);
|
this.changeLog.push(`counter: currentValue = ${cur}, previousValue = ${prev}`);
|
||||||
|
|
|
@ -57,7 +57,7 @@ export class PeekABooComponent extends PeekABooDirective implements
|
||||||
let changesMsgs: string[] = [];
|
let changesMsgs: string[] = [];
|
||||||
for (let propName in changes) {
|
for (let propName in changes) {
|
||||||
if (propName === 'name') {
|
if (propName === 'name') {
|
||||||
let name = changes['name'].currentValue;
|
let name = changes.name.currentValue;
|
||||||
changesMsgs.push(`name ${this.verb} to "${name}"`);
|
changesMsgs.push(`name ${this.verb} to "${name}"`);
|
||||||
} else {
|
} else {
|
||||||
changesMsgs.push(propName + ' ' + this.verb);
|
changesMsgs.push(propName + ' ' + this.verb);
|
||||||
|
|
|
@ -20,12 +20,12 @@ describe('Router', () => {
|
||||||
|
|
||||||
crisisHref: hrefEles.get(0),
|
crisisHref: hrefEles.get(0),
|
||||||
crisisList: element.all(by.css('app-root > div > app-crisis-center > app-crisis-list li')),
|
crisisList: element.all(by.css('app-root > div > app-crisis-center > app-crisis-list li')),
|
||||||
crisisDetail: crisisDetail,
|
crisisDetail,
|
||||||
crisisDetailTitle: crisisDetail.element(by.xpath('*[1]')),
|
crisisDetailTitle: crisisDetail.element(by.xpath('*[1]')),
|
||||||
|
|
||||||
heroesHref: hrefEles.get(1),
|
heroesHref: hrefEles.get(1),
|
||||||
heroesList: element.all(by.css('app-root > div > app-hero-list li')),
|
heroesList: element.all(by.css('app-root > div > app-hero-list li')),
|
||||||
heroDetail: heroDetail,
|
heroDetail,
|
||||||
heroDetailTitle: heroDetail.element(by.xpath('*[2]')),
|
heroDetailTitle: heroDetail.element(by.xpath('*[2]')),
|
||||||
|
|
||||||
adminHref: hrefEles.get(2),
|
adminHref: hrefEles.get(2),
|
||||||
|
|
|
@ -15,7 +15,7 @@ import { slideInAnimation } from './animations';
|
||||||
// #docregion function-binding
|
// #docregion function-binding
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
getAnimationData(outlet: RouterOutlet) {
|
getAnimationData(outlet: RouterOutlet) {
|
||||||
return outlet && outlet.activatedRouteData && outlet.activatedRouteData['animation'];
|
return outlet && outlet.activatedRouteData && outlet.activatedRouteData.animation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// #enddocregion function-binding
|
// #enddocregion function-binding
|
||||||
|
|
|
@ -12,6 +12,6 @@ import { slideInAnimation } from './animations';
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
getAnimationData(outlet: RouterOutlet) {
|
getAnimationData(outlet: RouterOutlet) {
|
||||||
return outlet && outlet.activatedRouteData && outlet.activatedRouteData['animation'];
|
return outlet && outlet.activatedRouteData && outlet.activatedRouteData.animation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ export class AuthGuard implements CanActivate, CanActivateChild {
|
||||||
// Set our navigation extras object
|
// Set our navigation extras object
|
||||||
// that contains our global query params and fragment
|
// that contains our global query params and fragment
|
||||||
let navigationExtras: NavigationExtras = {
|
let navigationExtras: NavigationExtras = {
|
||||||
queryParams: { 'session_id': sessionId },
|
queryParams: { session_id: sessionId },
|
||||||
fragment: 'anchor'
|
fragment: 'anchor'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ export class AuthGuard implements CanActivate, CanActivateChild, CanLoad {
|
||||||
// Set our navigation extras object
|
// Set our navigation extras object
|
||||||
// that contains our global query params and fragment
|
// that contains our global query params and fragment
|
||||||
let navigationExtras: NavigationExtras = {
|
let navigationExtras: NavigationExtras = {
|
||||||
queryParams: { 'session_id': sessionId },
|
queryParams: { session_id: sessionId },
|
||||||
fragment: 'anchor'
|
fragment: 'anchor'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ export class SelectivePreloadingStrategyService implements PreloadingStrategy {
|
||||||
preloadedModules: string[] = [];
|
preloadedModules: string[] = [];
|
||||||
|
|
||||||
preload(route: Route, load: () => Observable<any>): Observable<any> {
|
preload(route: Route, load: () => Observable<any>): Observable<any> {
|
||||||
if (route.data && route.data['preload']) {
|
if (route.data && route.data.preload) {
|
||||||
// add the route path to the preloaded module array
|
// add the route path to the preloaded module array
|
||||||
this.preloadedModules.push(route.path);
|
this.preloadedModules.push(route.path);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ describe('Testing Example', () => {
|
||||||
let navElts = element.all(by.css('app-root nav a'));
|
let navElts = element.all(by.css('app-root nav a'));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
navElts: navElts,
|
navElts,
|
||||||
|
|
||||||
appDashboard: element(by.css('app-root app-dashboard')),
|
appDashboard: element(by.css('app-root app-dashboard')),
|
||||||
};
|
};
|
||||||
|
|
|
@ -222,7 +222,7 @@ describe('demo (with TestBed):', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const ngForRow = fixture.debugElement.query(By.directive(IoComponent)); // first hero ngForRow
|
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');
|
expect(hero.name).toBe(heroName, 'ngRow.context.hero');
|
||||||
|
|
||||||
const rowComp = ngForRow.componentInstance;
|
const rowComp = ngForRow.componentInstance;
|
||||||
|
@ -514,11 +514,11 @@ describe('demo (with TestBed):', () => {
|
||||||
expect(comp.children.toArray().length).toBe(4,
|
expect(comp.children.toArray().length).toBe(4,
|
||||||
'three different child components and an ElementRef with #content');
|
'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
|
// #docregion custom-predicate
|
||||||
// Filter for DebugElements with a #content reference
|
// 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
|
// #enddocregion custom-predicate
|
||||||
expect(contentRefs.length).toBe(4, 'elements w/ a #content reference');
|
expect(contentRefs.length).toBe(4, 'elements w/ a #content reference');
|
||||||
});
|
});
|
||||||
|
|
|
@ -72,7 +72,7 @@ describe('HttpClient testing', () => {
|
||||||
|
|
||||||
// Make an HTTP GET request with specific header
|
// Make an HTTP GET request with specific header
|
||||||
httpClient.get<Data>(testUrl, {
|
httpClient.get<Data>(testUrl, {
|
||||||
headers: new HttpHeaders({'Authorization': 'my-auth-token'})
|
headers: new HttpHeaders({Authorization: 'my-auth-token'})
|
||||||
})
|
})
|
||||||
.subscribe(data =>
|
.subscribe(data =>
|
||||||
expect(data).toEqual(testData)
|
expect(data).toEqual(testData)
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe('CanvasComponent', () => {
|
||||||
// #enddocregion without-toBlob-macrotask
|
// #enddocregion without-toBlob-macrotask
|
||||||
// #docregion enable-toBlob-macrotask
|
// #docregion enable-toBlob-macrotask
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
window['__zone_symbol__FakeAsyncTestMacroTask'] = [
|
(window as any).__zone_symbol__FakeAsyncTestMacroTask = [
|
||||||
{
|
{
|
||||||
source: 'HTMLCanvasElement.toBlob',
|
source: 'HTMLCanvasElement.toBlob',
|
||||||
callbackArgs: [{ size: 200 }],
|
callbackArgs: [{ size: 200 }],
|
||||||
|
|
|
@ -69,7 +69,7 @@ describe('HighlightDirective', () => {
|
||||||
|
|
||||||
|
|
||||||
it('bare <h2> should not have a customProperty', () => {
|
it('bare <h2> should not have a customProperty', () => {
|
||||||
expect(bareH2.properties['customProperty']).toBeUndefined();
|
expect(bareH2.properties.customProperty).toBeUndefined();
|
||||||
});
|
});
|
||||||
// #enddocregion selected-tests
|
// #enddocregion selected-tests
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,13 @@ bootstrap();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
function bootstrap () {
|
function bootstrap() {
|
||||||
if (window['jasmineRef']) {
|
if ((window as any).jasmineRef) {
|
||||||
location.reload();
|
location.reload();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
window.onload(undefined);
|
window.onload(undefined);
|
||||||
window['jasmineRef'] = jasmine.getEnv();
|
(window as any).jasmineRef = jasmine.getEnv();
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, initialize the Angular testing environment.
|
// First, initialize the Angular testing environment.
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
import jasmineRequire from 'jasmine-core/lib/jasmine-core/jasmine.js';
|
import jasmineRequire from 'jasmine-core/lib/jasmine-core/jasmine.js';
|
||||||
|
|
||||||
window['jasmineRequire'] = jasmineRequire;
|
(window as any).jasmineRequire = jasmineRequire;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
export function addMatchers(): void {
|
export function addMatchers(): void {
|
||||||
jasmine.addMatchers({
|
jasmine.addMatchers({
|
||||||
toHaveText: toHaveText
|
toHaveText
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ describe('Tutorial part 5', () => {
|
||||||
let navElts = element.all(by.css('app-root nav a'));
|
let navElts = element.all(by.css('app-root nav a'));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
navElts: navElts,
|
navElts,
|
||||||
|
|
||||||
appDashboardHref: navElts.get(0),
|
appDashboardHref: navElts.get(0),
|
||||||
appDashboard: element(by.css('app-root app-dashboard')),
|
appDashboard: element(by.css('app-root app-dashboard')),
|
||||||
|
|
|
@ -50,7 +50,7 @@ describe('Tutorial part 6', () => {
|
||||||
let navElts = element.all(by.css('app-root nav a'));
|
let navElts = element.all(by.css('app-root nav a'));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
navElts: navElts,
|
navElts,
|
||||||
|
|
||||||
appDashboardHref: navElts.get(0),
|
appDashboardHref: navElts.get(0),
|
||||||
appDashboard: element(by.css('app-root app-dashboard')),
|
appDashboard: element(by.css('app-root app-dashboard')),
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe('phoneDetail', () => {
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
$httpBackend.expectGET('phones/xyz.json').respond(xyzPhoneData);
|
$httpBackend.expectGET('phones/xyz.json').respond(xyzPhoneData);
|
||||||
|
|
||||||
$routeParams['phoneId'] = 'xyz';
|
$routeParams.phoneId = 'xyz';
|
||||||
|
|
||||||
ctrl = $componentController('phoneDetail');
|
ctrl = $componentController('phoneDetail');
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -5,7 +5,7 @@ class PhoneDetailController {
|
||||||
|
|
||||||
static $inject = ['$routeParams', 'Phone'];
|
static $inject = ['$routeParams', 'Phone'];
|
||||||
constructor($routeParams: angular.route.IRouteParamsService, Phone: any) {
|
constructor($routeParams: angular.route.IRouteParamsService, Phone: any) {
|
||||||
let phoneId = $routeParams['phoneId'];
|
let phoneId = $routeParams.phoneId;
|
||||||
this.phone = Phone.get({phoneId}, (phone: any) => {
|
this.phone = Phone.get({phoneId}, (phone: any) => {
|
||||||
this.setImage(phone.images[0]);
|
this.setImage(phone.images[0]);
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,7 @@ class PhoneDetailController {
|
||||||
|
|
||||||
static $inject = ['$routeParams', 'phone'];
|
static $inject = ['$routeParams', 'phone'];
|
||||||
constructor($routeParams: angular.route.IRouteParamsService, phone: Phone) {
|
constructor($routeParams: angular.route.IRouteParamsService, phone: Phone) {
|
||||||
let phoneId = $routeParams['phoneId'];
|
let phoneId = $routeParams.phoneId;
|
||||||
phone.get(phoneId).subscribe(data => {
|
phone.get(phoneId).subscribe(data => {
|
||||||
this.phone = data;
|
this.phone = data;
|
||||||
this.setImage(data.images[0]);
|
this.setImage(data.images[0]);
|
||||||
|
|
|
@ -42,7 +42,7 @@ describe('PhoneDetailComponent', () => {
|
||||||
declarations: [ CheckmarkPipe, PhoneDetailComponent ],
|
declarations: [ CheckmarkPipe, PhoneDetailComponent ],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: Phone, useClass: MockPhone },
|
{ provide: Phone, useClass: MockPhone },
|
||||||
{ provide: ActivatedRoute, useValue: new ActivatedRouteMock({ params: { 'phoneId': 1 } }) }
|
{ provide: ActivatedRoute, useValue: new ActivatedRouteMock({ params: { phoneId: 1 } }) }
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
|
@ -22,7 +22,7 @@ export class PhoneDetailComponent {
|
||||||
mainImageUrl: string;
|
mainImageUrl: string;
|
||||||
|
|
||||||
constructor(routeParams: RouteParams, phone: Phone) {
|
constructor(routeParams: RouteParams, phone: Phone) {
|
||||||
phone.get(routeParams['phoneId']).subscribe(phone => {
|
phone.get(routeParams.phoneId).subscribe(phone => {
|
||||||
this.phone = phone;
|
this.phone = phone;
|
||||||
this.setImage(phone.images[0]);
|
this.setImage(phone.images[0]);
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,7 +42,7 @@ describe('PhoneDetailComponent', () => {
|
||||||
declarations: [ CheckmarkPipe, PhoneDetailComponent ],
|
declarations: [ CheckmarkPipe, PhoneDetailComponent ],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: Phone, useClass: MockPhone },
|
{ provide: Phone, useClass: MockPhone },
|
||||||
{ provide: ActivatedRoute, useValue: new ActivatedRouteMock({ params: { 'phoneId': 1 } }) }
|
{ provide: ActivatedRoute, useValue: new ActivatedRouteMock({ params: { phoneId: 1 } }) }
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
Loading…
Reference in New Issue