refactor(): use const and let instead of var

This commit is contained in:
Joao Dias
2016-11-12 14:08:58 +01:00
committed by Victor Berchet
parent 73593d4bf3
commit 77ee27c59e
435 changed files with 4637 additions and 4663 deletions

View File

@ -42,7 +42,7 @@ export function main() {
}
function queryDirs(el: DebugElement, dirType: Type<any>): any {
var nodes = el.queryAllNodes(By.directive(dirType));
const nodes = el.queryAllNodes(By.directive(dirType));
return nodes.map(node => node.injector.get(dirType));
}
@ -50,7 +50,7 @@ export function main() {
function _bindSimpleProp<T>(bindAttr: string, compType: Type<T>): ComponentFixture<T>;
function _bindSimpleProp<T>(
bindAttr: string, compType: Type<T> = <any>TestComponent): ComponentFixture<T> {
var template = `<div ${bindAttr}></div>`;
const template = `<div ${bindAttr}></div>`;
return createCompFixture(template, compType);
}
@ -242,14 +242,14 @@ export function main() {
}));
it('should report all changes on the first run including null values', fakeAsync(() => {
var ctx = _bindSimpleValue('a', TestData);
const ctx = _bindSimpleValue('a', TestData);
ctx.componentInstance.a = null;
ctx.detectChanges(false);
expect(renderLog.log).toEqual(['someProp=null']);
}));
it('should support simple chained property access', fakeAsync(() => {
var ctx = _bindSimpleValue('address.city', Person);
const ctx = _bindSimpleValue('address.city', Person);
ctx.componentInstance.name = 'Victor';
ctx.componentInstance.address = new Address('Grenoble');
ctx.detectChanges(false);
@ -258,28 +258,28 @@ export function main() {
describe('safe navigation operator', () => {
it('should support reading properties of nulls', fakeAsync(() => {
var ctx = _bindSimpleValue('address?.city', Person);
const ctx = _bindSimpleValue('address?.city', Person);
ctx.componentInstance.address = null;
ctx.detectChanges(false);
expect(renderLog.log).toEqual(['someProp=null']);
}));
it('should support calling methods on nulls', fakeAsync(() => {
var ctx = _bindSimpleValue('address?.toString()', Person);
const ctx = _bindSimpleValue('address?.toString()', Person);
ctx.componentInstance.address = null;
ctx.detectChanges(false);
expect(renderLog.log).toEqual(['someProp=null']);
}));
it('should support reading properties on non nulls', fakeAsync(() => {
var ctx = _bindSimpleValue('address?.city', Person);
const ctx = _bindSimpleValue('address?.city', Person);
ctx.componentInstance.address = new Address('MTV');
ctx.detectChanges(false);
expect(renderLog.log).toEqual(['someProp=MTV']);
}));
it('should support calling methods on non nulls', fakeAsync(() => {
var ctx = _bindSimpleValue('address?.toString()', Person);
const ctx = _bindSimpleValue('address?.toString()', Person);
ctx.componentInstance.address = new Address('MTV');
ctx.detectChanges(false);
expect(renderLog.log).toEqual(['someProp=MTV']);
@ -317,27 +317,27 @@ export function main() {
});
it('should support method calls', fakeAsync(() => {
var ctx = _bindSimpleValue('sayHi("Jim")', Person);
const ctx = _bindSimpleValue('sayHi("Jim")', Person);
ctx.detectChanges(false);
expect(renderLog.log).toEqual(['someProp=Hi, Jim']);
}));
it('should support function calls', fakeAsync(() => {
var ctx = _bindSimpleValue('a()(99)', TestData);
const ctx = _bindSimpleValue('a()(99)', TestData);
ctx.componentInstance.a = () => (a: any) => a;
ctx.detectChanges(false);
expect(renderLog.log).toEqual(['someProp=99']);
}));
it('should support chained method calls', fakeAsync(() => {
var ctx = _bindSimpleValue('address.toString()', Person);
const ctx = _bindSimpleValue('address.toString()', Person);
ctx.componentInstance.address = new Address('MTV');
ctx.detectChanges(false);
expect(renderLog.log).toEqual(['someProp=MTV']);
}));
it('should support NaN', fakeAsync(() => {
var ctx = _bindSimpleValue('age', Person);
const ctx = _bindSimpleValue('age', Person);
ctx.componentInstance.age = NaN;
ctx.detectChanges(false);
@ -349,7 +349,7 @@ export function main() {
}));
it('should do simple watching', fakeAsync(() => {
var ctx = _bindSimpleValue('name', Person);
const ctx = _bindSimpleValue('name', Person);
ctx.componentInstance.name = 'misko';
ctx.detectChanges(false);
@ -366,26 +366,26 @@ export function main() {
}));
it('should support literal array made of literals', fakeAsync(() => {
var ctx = _bindSimpleValue('[1, 2]');
const ctx = _bindSimpleValue('[1, 2]');
ctx.detectChanges(false);
expect(renderLog.loggedValues).toEqual([[1, 2]]);
}));
it('should support empty literal array', fakeAsync(() => {
var ctx = _bindSimpleValue('[]');
const ctx = _bindSimpleValue('[]');
ctx.detectChanges(false);
expect(renderLog.loggedValues).toEqual([[]]);
}));
it('should support literal array made of expressions', fakeAsync(() => {
var ctx = _bindSimpleValue('[1, a]', TestData);
const ctx = _bindSimpleValue('[1, a]', TestData);
ctx.componentInstance.a = 2;
ctx.detectChanges(false);
expect(renderLog.loggedValues).toEqual([[1, 2]]);
}));
it('should not recreate literal arrays unless their content changed', fakeAsync(() => {
var ctx = _bindSimpleValue('[1, a]', TestData);
const ctx = _bindSimpleValue('[1, a]', TestData);
ctx.componentInstance.a = 2;
ctx.detectChanges(false);
ctx.detectChanges(false);
@ -396,26 +396,26 @@ export function main() {
}));
it('should support literal maps made of literals', fakeAsync(() => {
var ctx = _bindSimpleValue('{z: 1}');
const ctx = _bindSimpleValue('{z: 1}');
ctx.detectChanges(false);
expect(renderLog.loggedValues[0]['z']).toEqual(1);
}));
it('should support empty literal map', fakeAsync(() => {
var ctx = _bindSimpleValue('{}');
const ctx = _bindSimpleValue('{}');
ctx.detectChanges(false);
expect(renderLog.loggedValues).toEqual([{}]);
}));
it('should support literal maps made of expressions', fakeAsync(() => {
var ctx = _bindSimpleValue('{z: a}');
const ctx = _bindSimpleValue('{z: a}');
ctx.componentInstance.a = 1;
ctx.detectChanges(false);
expect(renderLog.loggedValues[0]['z']).toEqual(1);
}));
it('should not recreate literal maps unless their content changed', fakeAsync(() => {
var ctx = _bindSimpleValue('{z: a}');
const ctx = _bindSimpleValue('{z: a}');
ctx.componentInstance.a = 1;
ctx.detectChanges(false);
ctx.detectChanges(false);
@ -429,7 +429,7 @@ export function main() {
it('should ignore empty bindings', fakeAsync(() => {
var ctx = _bindSimpleProp('[someProp]', TestData);
const ctx = _bindSimpleProp('[someProp]', TestData);
ctx.componentInstance.a = 'value';
ctx.detectChanges(false);
@ -437,7 +437,7 @@ export function main() {
}));
it('should support interpolation', fakeAsync(() => {
var ctx = _bindSimpleProp('someProp="B{{a}}A"', TestData);
const ctx = _bindSimpleProp('someProp="B{{a}}A"', TestData);
ctx.componentInstance.a = 'value';
ctx.detectChanges(false);
@ -445,7 +445,7 @@ export function main() {
}));
it('should output empty strings for null values in interpolation', fakeAsync(() => {
var ctx = _bindSimpleProp('someProp="B{{a}}A"', TestData);
const ctx = _bindSimpleProp('someProp="B{{a}}A"', TestData);
ctx.componentInstance.a = null;
ctx.detectChanges(false);
@ -456,7 +456,7 @@ export function main() {
fakeAsync(() => { expect(_bindAndCheckSimpleValue('"$"')).toEqual(['someProp=$']); }));
it('should read locals', fakeAsync(() => {
var ctx =
const ctx =
createCompFixture('<template testLocals let-local="someLocal">{{local}}</template>');
ctx.detectChanges(false);
@ -465,14 +465,14 @@ export function main() {
describe('pipes', () => {
it('should use the return value of the pipe', fakeAsync(() => {
var ctx = _bindSimpleValue('name | countingPipe', Person);
const ctx = _bindSimpleValue('name | countingPipe', Person);
ctx.componentInstance.name = 'bob';
ctx.detectChanges(false);
expect(renderLog.loggedValues).toEqual(['bob state:0']);
}));
it('should support arguments in pipes', fakeAsync(() => {
var ctx = _bindSimpleValue('name | multiArgPipe:"one":address.city', Person);
const ctx = _bindSimpleValue('name | multiArgPipe:"one":address.city', Person);
ctx.componentInstance.name = 'value';
ctx.componentInstance.address = new Address('two');
ctx.detectChanges(false);
@ -480,21 +480,22 @@ export function main() {
}));
it('should associate pipes right-to-left', fakeAsync(() => {
var ctx = _bindSimpleValue('name | multiArgPipe:"a":"b" | multiArgPipe:0:1', Person);
const ctx = _bindSimpleValue('name | multiArgPipe:"a":"b" | multiArgPipe:0:1', Person);
ctx.componentInstance.name = 'value';
ctx.detectChanges(false);
expect(renderLog.loggedValues).toEqual(['value a b default 0 1 default']);
}));
it('should support calling pure pipes with different number of arguments', fakeAsync(() => {
var ctx = _bindSimpleValue('name | multiArgPipe:"a":"b" | multiArgPipe:0:1:2', Person);
const ctx =
_bindSimpleValue('name | multiArgPipe:"a":"b" | multiArgPipe:0:1:2', Person);
ctx.componentInstance.name = 'value';
ctx.detectChanges(false);
expect(renderLog.loggedValues).toEqual(['value a b default 0 1 2']);
}));
it('should do nothing when no change', fakeAsync(() => {
var ctx = _bindSimpleValue('"Megatron" | identityPipe', Person);
const ctx = _bindSimpleValue('"Megatron" | identityPipe', Person);
ctx.detectChanges(false);
@ -507,7 +508,7 @@ export function main() {
}));
it('should unwrap the wrapped value', fakeAsync(() => {
var ctx = _bindSimpleValue('"Megatron" | wrappedPipe', Person);
const ctx = _bindSimpleValue('"Megatron" | wrappedPipe', Person);
ctx.detectChanges(false);
@ -520,7 +521,7 @@ export function main() {
}));
it('should call pure pipes only if the arguments change', fakeAsync(() => {
var ctx = _bindSimpleValue('name | countingPipe', Person);
const ctx = _bindSimpleValue('name | countingPipe', Person);
// change from undefined -> null
ctx.componentInstance.name = null;
ctx.detectChanges(false);
@ -550,7 +551,7 @@ export function main() {
it('should call pure pipes that are used multiple times only when the arguments change',
fakeAsync(() => {
var ctx = createCompFixture(
const ctx = createCompFixture(
`<div [someProp]="name | countingPipe"></div><div [someProp]="age | countingPipe"></div>` +
'<div *ngFor="let x of [1,2]" [someProp]="address.city | countingPipe"></div>',
Person);
@ -573,7 +574,7 @@ export function main() {
}));
it('should call impure pipes on each change detection run', fakeAsync(() => {
var ctx = _bindSimpleValue('name | countingImpurePipe', Person);
const ctx = _bindSimpleValue('name | countingImpurePipe', Person);
ctx.componentInstance.name = 'bob';
ctx.detectChanges(false);
expect(renderLog.loggedValues).toEqual(['bob state:0']);
@ -584,9 +585,9 @@ export function main() {
describe('event expressions', () => {
it('should support field assignments', fakeAsync(() => {
var ctx = _bindSimpleProp('(event)="b=a=$event"');
var childEl = ctx.debugElement.children[0];
var evt = 'EVENT';
const ctx = _bindSimpleProp('(event)="b=a=$event"');
const childEl = ctx.debugElement.children[0];
const evt = 'EVENT';
childEl.triggerEventHandler('event', evt);
expect(ctx.componentInstance.a).toEqual(evt);
@ -594,17 +595,17 @@ export function main() {
}));
it('should support keyed assignments', fakeAsync(() => {
var ctx = _bindSimpleProp('(event)="a[0]=$event"');
var childEl = ctx.debugElement.children[0];
const ctx = _bindSimpleProp('(event)="a[0]=$event"');
const childEl = ctx.debugElement.children[0];
ctx.componentInstance.a = ['OLD'];
var evt = 'EVENT';
const evt = 'EVENT';
childEl.triggerEventHandler('event', evt);
expect(ctx.componentInstance.a).toEqual([evt]);
}));
it('should support chains', fakeAsync(() => {
var ctx = _bindSimpleProp('(event)="a=a+1; a=a+1;"');
var childEl = ctx.debugElement.children[0];
const ctx = _bindSimpleProp('(event)="a=a+1; a=a+1;"');
const childEl = ctx.debugElement.children[0];
ctx.componentInstance.a = 0;
childEl.triggerEventHandler('event', 'EVENT');
expect(ctx.componentInstance.a).toEqual(2);
@ -617,8 +618,8 @@ export function main() {
}));
it('should support short-circuiting', fakeAsync(() => {
var ctx = _bindSimpleProp('(event)="true ? a = a + 1 : a = a + 1"');
var childEl = ctx.debugElement.children[0];
const ctx = _bindSimpleProp('(event)="true ? a = a + 1 : a = a + 1"');
const childEl = ctx.debugElement.children[0];
ctx.componentInstance.a = 0;
childEl.triggerEventHandler('event', 'EVENT');
expect(ctx.componentInstance.a).toEqual(1);
@ -630,7 +631,7 @@ export function main() {
describe('change notification', () => {
describe('updating directives', () => {
it('should happen without invoking the renderer', fakeAsync(() => {
var ctx = createCompFixture('<div testDirective [a]="42"></div>');
const ctx = createCompFixture('<div testDirective [a]="42"></div>');
ctx.detectChanges(false);
expect(renderLog.log).toEqual([]);
expect(queryDirs(ctx.debugElement, TestDirective)[0].a).toEqual(42);
@ -639,7 +640,7 @@ export function main() {
describe('reading directives', () => {
it('should read directive properties', fakeAsync(() => {
var ctx = createCompFixture(
const ctx = createCompFixture(
'<div testDirective [a]="42" ref-dir="testDirective" [someProp]="dir.a"></div>');
ctx.detectChanges(false);
expect(renderLog.loggedValues).toEqual([42]);
@ -648,11 +649,11 @@ export function main() {
describe('ngOnChanges', () => {
it('should notify the directive when a group of records changes', fakeAsync(() => {
var ctx = createCompFixture(
const ctx = createCompFixture(
'<div [testDirective]="\'aName\'" [a]="1" [b]="2"></div><div [testDirective]="\'bName\'" [a]="4"></div>');
ctx.detectChanges(false);
var dirs = queryDirs(ctx.debugElement, TestDirective);
const dirs = queryDirs(ctx.debugElement, TestDirective);
expect(dirs[0].changes).toEqual({'a': 1, 'b': 2, 'name': 'aName'});
expect(dirs[1].changes).toEqual({'a': 4, 'name': 'bName'});
}));
@ -675,7 +676,7 @@ export function main() {
describe('ngOnInit', () => {
it('should be called after ngOnChanges', fakeAsync(() => {
var ctx = createCompFixture('<div testDirective="dir"></div>');
const ctx = createCompFixture('<div testDirective="dir"></div>');
expect(directiveLog.filter(['ngOnInit', 'ngOnChanges'])).toEqual([]);
ctx.detectChanges(false);
@ -691,7 +692,7 @@ export function main() {
}));
it('should only be called only once', fakeAsync(() => {
var ctx = createCompFixture('<div testDirective="dir"></div>');
const ctx = createCompFixture('<div testDirective="dir"></div>');
ctx.detectChanges(false);
@ -712,9 +713,9 @@ export function main() {
}));
it('should not call ngOnInit again if it throws', fakeAsync(() => {
var ctx = createCompFixture('<div testDirective="dir" throwOn="ngOnInit"></div>');
const ctx = createCompFixture('<div testDirective="dir" throwOn="ngOnInit"></div>');
var errored = false;
let errored = false;
// First pass fails, but ngOnInit should be called.
try {
ctx.detectChanges(false);
@ -738,7 +739,7 @@ export function main() {
describe('ngDoCheck', () => {
it('should be called after ngOnInit', fakeAsync(() => {
var ctx = createCompFixture('<div testDirective="dir"></div>');
const ctx = createCompFixture('<div testDirective="dir"></div>');
ctx.detectChanges(false);
expect(directiveLog.filter(['ngDoCheck', 'ngOnInit'])).toEqual([
@ -748,7 +749,7 @@ export function main() {
it('should be called on every detectChanges run, except for checkNoChanges',
fakeAsync(() => {
var ctx = createCompFixture('<div testDirective="dir"></div>');
const ctx = createCompFixture('<div testDirective="dir"></div>');
ctx.detectChanges(false);
@ -772,7 +773,7 @@ export function main() {
describe('ngAfterContentInit', () => {
it('should be called after processing the content children but before the view children',
fakeAsync(() => {
var ctx = createCompWithContentAndViewChild();
const ctx = createCompWithContentAndViewChild();
ctx.detectChanges(false);
expect(directiveLog.filter(['ngDoCheck', 'ngAfterContentInit'])).toEqual([
@ -782,7 +783,7 @@ export function main() {
}));
it('should only be called only once', fakeAsync(() => {
var ctx = createCompFixture('<div testDirective="dir"></div>');
const ctx = createCompFixture('<div testDirective="dir"></div>');
ctx.detectChanges(false);
@ -805,10 +806,10 @@ export function main() {
}));
it('should not call ngAfterContentInit again if it throws', fakeAsync(() => {
var ctx =
const ctx =
createCompFixture('<div testDirective="dir" throwOn="ngAfterContentInit"></div>');
var errored = false;
let errored = false;
// First pass fails, but ngAfterContentInit should be called.
try {
ctx.detectChanges(false);
@ -836,7 +837,7 @@ export function main() {
describe('ngAfterContentChecked', () => {
it('should be called after the content children but before the view children',
fakeAsync(() => {
var ctx = createCompWithContentAndViewChild();
const ctx = createCompWithContentAndViewChild();
ctx.detectChanges(false);
@ -849,7 +850,7 @@ export function main() {
it('should be called on every detectChanges run, except for checkNoChanges',
fakeAsync(() => {
var ctx = createCompFixture('<div testDirective="dir"></div>');
const ctx = createCompFixture('<div testDirective="dir"></div>');
ctx.detectChanges(false);
@ -875,7 +876,7 @@ export function main() {
it('should be called in reverse order so the child is always notified before the parent',
fakeAsync(() => {
var ctx = createCompFixture(
const ctx = createCompFixture(
'<div testDirective="parent"><div testDirective="child"></div></div>');
ctx.detectChanges(false);
@ -889,7 +890,7 @@ export function main() {
describe('ngAfterViewInit', () => {
it('should be called after processing the view children', fakeAsync(() => {
var ctx = createCompWithContentAndViewChild();
const ctx = createCompWithContentAndViewChild();
ctx.detectChanges(false);
@ -900,7 +901,7 @@ export function main() {
}));
it('should only be called only once', fakeAsync(() => {
var ctx = createCompFixture('<div testDirective="dir"></div>');
const ctx = createCompFixture('<div testDirective="dir"></div>');
ctx.detectChanges(false);
@ -921,10 +922,10 @@ export function main() {
}));
it('should not call ngAfterViewInit again if it throws', fakeAsync(() => {
var ctx =
const ctx =
createCompFixture('<div testDirective="dir" throwOn="ngAfterViewInit"></div>');
var errored = false;
let errored = false;
// First pass fails, but ngAfterViewInit should be called.
try {
ctx.detectChanges(false);
@ -949,7 +950,7 @@ export function main() {
describe('ngAfterViewChecked', () => {
it('should be called after processing the view children', fakeAsync(() => {
var ctx = createCompWithContentAndViewChild();
const ctx = createCompWithContentAndViewChild();
ctx.detectChanges(false);
@ -961,7 +962,7 @@ export function main() {
it('should be called on every detectChanges run, except for checkNoChanges',
fakeAsync(() => {
var ctx = createCompFixture('<div testDirective="dir"></div>');
const ctx = createCompFixture('<div testDirective="dir"></div>');
ctx.detectChanges(false);
@ -987,7 +988,7 @@ export function main() {
it('should be called in reverse order so the child is always notified before the parent',
fakeAsync(() => {
var ctx = createCompFixture(
const ctx = createCompFixture(
'<div testDirective="parent"><div testDirective="child"></div></div>');
ctx.detectChanges(false);
@ -1000,7 +1001,7 @@ export function main() {
describe('ngOnDestroy', () => {
it('should be called on view destruction', fakeAsync(() => {
var ctx = createCompFixture('<div testDirective="dir"></div>');
const ctx = createCompFixture('<div testDirective="dir"></div>');
ctx.detectChanges(false);
ctx.destroy();
@ -1014,7 +1015,7 @@ export function main() {
{selector: 'other-cmp', template: '<div testDirective="viewChild"></div>'})
});
var ctx = createCompFixture(
const ctx = createCompFixture(
'<div testDirective="parent"><div *ngFor="let x of [0,1]" testDirective="contentChild{{x}}"></div>' +
'<other-cmp></other-cmp></div>',
TestComponent);
@ -1030,7 +1031,7 @@ export function main() {
it('should be called in reverse order so the child is always notified before the parent',
fakeAsync(() => {
var ctx = createCompFixture(
const ctx = createCompFixture(
'<div testDirective="parent"><div testDirective="child"></div></div>');
ctx.detectChanges(false);
@ -1042,7 +1043,7 @@ export function main() {
}));
it('should deliver synchronous events to parent', fakeAsync(() => {
var ctx = createCompFixture('<div (destroy)="a=$event" onDestroyDirective></div>');
const ctx = createCompFixture('<div (destroy)="a=$event" onDestroyDirective></div>');
ctx.detectChanges(false);
ctx.destroy();
@ -1051,7 +1052,7 @@ export function main() {
}));
it('should call ngOnDestroy on pipes', fakeAsync(() => {
var ctx = createCompFixture('{{true | pipeWithOnDestroy }}');
const ctx = createCompFixture('{{true | pipeWithOnDestroy }}');
ctx.detectChanges(false);
ctx.destroy();
@ -1065,7 +1066,7 @@ export function main() {
TestBed.overrideDirective(
TestDirective, {set: {providers: [InjectableWithLifecycle]}});
var ctx = createCompFixture('<div testDirective="dir"></div>', TestComponent);
const ctx = createCompFixture('<div testDirective="dir"></div>', TestComponent);
ctx.debugElement.children[0].injector.get(InjectableWithLifecycle);
ctx.detectChanges(false);
@ -1116,8 +1117,8 @@ export function main() {
describe('mode', () => {
it('Detached', fakeAsync(() => {
var ctx = createCompFixture('<comp-with-ref></comp-with-ref>');
var cmp: CompWithRef = queryDirs(ctx.debugElement, CompWithRef)[0];
const ctx = createCompFixture('<comp-with-ref></comp-with-ref>');
const cmp: CompWithRef = queryDirs(ctx.debugElement, CompWithRef)[0];
cmp.value = 'hello';
cmp.changeDetectorRef.detach();
@ -1127,8 +1128,8 @@ export function main() {
}));
it('Reattaches', fakeAsync(() => {
var ctx = createCompFixture('<comp-with-ref></comp-with-ref>');
var cmp: CompWithRef = queryDirs(ctx.debugElement, CompWithRef)[0];
const ctx = createCompFixture('<comp-with-ref></comp-with-ref>');
const cmp: CompWithRef = queryDirs(ctx.debugElement, CompWithRef)[0];
cmp.value = 'hello';
cmp.changeDetectorRef.detach();
@ -1146,8 +1147,8 @@ export function main() {
}));
it('Reattaches in the original cd mode', fakeAsync(() => {
var ctx = createCompFixture('<push-cmp></push-cmp>');
var cmp: PushComp = queryDirs(ctx.debugElement, PushComp)[0];
const ctx = createCompFixture('<push-cmp></push-cmp>');
const cmp: PushComp = queryDirs(ctx.debugElement, PushComp)[0];
cmp.changeDetectorRef.detach();
cmp.changeDetectorRef.reattach();
@ -1155,7 +1156,7 @@ export function main() {
// on-push
ctx.detectChanges();
expect(cmp.renderCount).toBeGreaterThan(0);
var count = cmp.renderCount;
const count = cmp.renderCount;
ctx.detectChanges();
expect(cmp.renderCount).toBe(count);
@ -1166,7 +1167,7 @@ export function main() {
describe('multi directive order', () => {
it('should follow the DI order for the same element', fakeAsync(() => {
var ctx =
const ctx =
createCompFixture('<div orderCheck2="2" orderCheck0="0" orderCheck1="1"></div>');
ctx.detectChanges(false);
@ -1525,7 +1526,7 @@ class Person {
passThrough(val: any): any { return val; }
toString(): string {
var address = this.address == null ? '' : ' address=' + this.address.toString();
const address = this.address == null ? '' : ' address=' + this.address.toString();
return 'name=' + this.name + address;
}

View File

@ -27,7 +27,7 @@ class DummyConsole implements Console {
function declareTests({useJit}: {useJit: boolean}) {
describe('@Component.entryComponents', function() {
var console: DummyConsole;
let console: DummyConsole;
beforeEach(() => {
console = new DummyConsole();
TestBed.configureCompiler(
@ -37,9 +37,9 @@ function declareTests({useJit}: {useJit: boolean}) {
it('should resolve ComponentFactories from the same component', () => {
const compFixture = TestBed.createComponent(MainComp);
let mainComp: MainComp = compFixture.componentInstance;
const mainComp: MainComp = compFixture.componentInstance;
expect(compFixture.componentRef.injector.get(ComponentFactoryResolver)).toBe(mainComp.cfr);
var cf = mainComp.cfr.resolveComponentFactory(ChildComp);
const cf = mainComp.cfr.resolveComponentFactory(ChildComp);
expect(cf.componentType).toBe(ChildComp);
});
@ -47,9 +47,9 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.resetTestingModule();
TestBed.configureTestingModule(
{declarations: [CompWithAnalyzeEntryComponentsProvider, NestedChildComp, ChildComp]});
let compFixture = TestBed.createComponent(CompWithAnalyzeEntryComponentsProvider);
let mainComp: CompWithAnalyzeEntryComponentsProvider = compFixture.componentInstance;
let cfr: ComponentFactoryResolver =
const compFixture = TestBed.createComponent(CompWithAnalyzeEntryComponentsProvider);
const mainComp: CompWithAnalyzeEntryComponentsProvider = compFixture.componentInstance;
const cfr: ComponentFactoryResolver =
compFixture.componentRef.injector.get(ComponentFactoryResolver);
expect(cfr.resolveComponentFactory(ChildComp).componentType).toBe(ChildComp);
expect(cfr.resolveComponentFactory(NestedChildComp).componentType).toBe(NestedChildComp);
@ -59,8 +59,8 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MainComp, {set: {template: '<child></child>'}});
const compFixture = TestBed.createComponent(MainComp);
let childCompEl = compFixture.debugElement.children[0];
let childComp: ChildComp = childCompEl.componentInstance;
const childCompEl = compFixture.debugElement.children[0];
const childComp: ChildComp = childCompEl.componentInstance;
// declared on ChildComp directly
expect(childComp.cfr.resolveComponentFactory(NestedChildComp).componentType)
.toBe(NestedChildComp);
@ -73,8 +73,8 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(ChildComp, {set: {template: '<ng-content></ng-content>'}});
const compFixture = TestBed.createComponent(MainComp);
let nestedChildCompEl = compFixture.debugElement.children[0].children[0];
let nestedChildComp: NestedChildComp = nestedChildCompEl.componentInstance;
const nestedChildCompEl = compFixture.debugElement.children[0].children[0];
const nestedChildComp: NestedChildComp = nestedChildCompEl.componentInstance;
expect(nestedChildComp.cfr.resolveComponentFactory(ChildComp).componentType).toBe(ChildComp);
expect(() => nestedChildComp.cfr.resolveComponentFactory(NestedChildComp))
.toThrow(new NoComponentFactoryError(NestedChildComp));

View File

@ -208,7 +208,7 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var nativeEl = fixture.debugElement.children[0].nativeElement;
const nativeEl = fixture.debugElement.children[0].nativeElement;
fixture.componentInstance.ctxProp = 'foo bar';
fixture.detectChanges();
@ -244,7 +244,7 @@ function declareTests({useJit}: {useJit: boolean}) {
fixture.componentInstance.ctxProp = 'Hello World!';
fixture.detectChanges();
var containerSpan = fixture.debugElement.children[0];
const containerSpan = fixture.debugElement.children[0];
expect(containerSpan.children[0].injector.get(MyDir).dirProp).toEqual('Hello World!');
expect(containerSpan.children[1].injector.get(MyDir).dirProp).toEqual('Hi there!');
@ -263,7 +263,7 @@ function declareTests({useJit}: {useJit: boolean}) {
fixture.componentInstance.ctxProp = 'a';
fixture.detectChanges();
var dir = fixture.debugElement.children[0].references['dir'];
const dir = fixture.debugElement.children[0].references['dir'];
expect(dir.dirProp).toEqual('aa');
});
});
@ -289,7 +289,7 @@ function declareTests({useJit}: {useJit: boolean}) {
fixture.componentInstance.ctxProp = 'Hello World!';
fixture.detectChanges();
var tc = fixture.debugElement.children[0];
const tc = fixture.debugElement.children[0];
expect(tc.injector.get(MyDir).dirProp).toEqual('Hello World!');
expect(tc.injector.get(ChildComp).dirProp).toEqual(null);
@ -317,8 +317,8 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var tc = fixture.debugElement.children[0];
var idDir = tc.injector.get(IdDir);
const tc = fixture.debugElement.children[0];
const idDir = tc.injector.get(IdDir);
fixture.componentInstance.ctxProp = 'some_id';
fixture.detectChanges();
@ -335,7 +335,7 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var tc = fixture.debugElement.children[0];
const tc = fixture.debugElement.children[0];
expect(tc.injector.get(EventDir)).not.toBe(null);
});
@ -355,7 +355,7 @@ function declareTests({useJit}: {useJit: boolean}) {
fixture.detectChanges();
var childNodesOfWrapper = getDOM().childNodes(fixture.nativeElement);
const childNodesOfWrapper = getDOM().childNodes(fixture.nativeElement);
// 1 template + 2 copies.
expect(childNodesOfWrapper.length).toBe(3);
expect(childNodesOfWrapper[1]).toHaveText('hello');
@ -383,8 +383,8 @@ function declareTests({useJit}: {useJit: boolean}) {
fixture.componentInstance.ctxBoolProp = true;
fixture.detectChanges();
var ngIfEl = fixture.debugElement.children[0];
var someViewport: SomeViewport = ngIfEl.childNodes[0].injector.get(SomeViewport);
const ngIfEl = fixture.debugElement.children[0];
const someViewport: SomeViewport = ngIfEl.childNodes[0].injector.get(SomeViewport);
expect(someViewport.container.length).toBe(2);
expect(ngIfEl.children.length).toBe(2);
@ -401,7 +401,7 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var childNodesOfWrapper = getDOM().childNodes(fixture.nativeElement);
const childNodesOfWrapper = getDOM().childNodes(fixture.nativeElement);
expect(childNodesOfWrapper.length).toBe(1);
expect(getDOM().isCommentNode(childNodesOfWrapper[0])).toBe(true);
});
@ -415,7 +415,7 @@ function declareTests({useJit}: {useJit: boolean}) {
fixture.detectChanges();
var childNodesOfWrapper = getDOM().childNodes(fixture.nativeElement);
const childNodesOfWrapper = getDOM().childNodes(fixture.nativeElement);
// 1 template + 2 copies.
expect(childNodesOfWrapper.length).toBe(3);
expect(childNodesOfWrapper[1]).toHaveText('hello');
@ -483,10 +483,10 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var pEl = fixture.debugElement.children[0];
const pEl = fixture.debugElement.children[0];
var alice = pEl.children[0].references['alice'];
var bob = pEl.children[1].references['bob'];
const alice = pEl.children[0].references['alice'];
const bob = pEl.children[1].references['bob'];
expect(alice).toBeAnInstanceOf(ChildComp);
expect(bob).toBeAnInstanceOf(ChildComp);
expect(alice).not.toBe(bob);
@ -507,7 +507,7 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var value = fixture.debugElement.children[0].children[0].references['alice'];
const value = fixture.debugElement.children[0].children[0].references['alice'];
expect(value).not.toBe(null);
expect(value.tagName.toLowerCase()).toEqual('div');
});
@ -518,7 +518,7 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var value = fixture.debugElement.childNodes[0].references['alice'];
const value = fixture.debugElement.childNodes[0].references['alice'];
expect(value).toBeAnInstanceOf(TemplateRef_);
});
@ -555,7 +555,7 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var cmp = fixture.debugElement.children[0].references['cmp'];
const cmp = fixture.debugElement.children[0].references['cmp'];
fixture.detectChanges();
expect(cmp.numberOfChecks).toEqual(1);
@ -576,7 +576,7 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var cmp = fixture.debugElement.children[0].references['cmp'];
const cmp = fixture.debugElement.children[0].references['cmp'];
fixture.componentInstance.ctxProp = 'one';
fixture.detectChanges();
@ -598,8 +598,8 @@ function declareTests({useJit}: {useJit: boolean}) {
tick();
fixture.detectChanges();
var cmpEl = fixture.debugElement.children[0];
var cmp: PushCmpWithHostEvent = cmpEl.injector.get(PushCmpWithHostEvent);
const cmpEl = fixture.debugElement.children[0];
const cmp: PushCmpWithHostEvent = cmpEl.injector.get(PushCmpWithHostEvent);
cmp.ctxCallback = (_: any) => fixture.destroy();
expect(() => cmpEl.triggerEventHandler('click', <Event>{})).not.toThrow();
@ -613,8 +613,8 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var cmpEl = fixture.debugElement.children[0];
var cmp = cmpEl.componentInstance;
const cmpEl = fixture.debugElement.children[0];
const cmp = cmpEl.componentInstance;
fixture.detectChanges();
fixture.detectChanges();
expect(cmp.numberOfChecks).toEqual(1);
@ -647,7 +647,7 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var cmp = fixture.debugElement.children[0].references['cmp'];
const cmp = fixture.debugElement.children[0].references['cmp'];
fixture.componentInstance.ctxProp = 'one';
fixture.detectChanges();
@ -668,7 +668,7 @@ function declareTests({useJit}: {useJit: boolean}) {
tick();
var cmp: PushCmpWithAsyncPipe = fixture.debugElement.children[0].references['cmp'];
const cmp: PushCmpWithAsyncPipe = fixture.debugElement.children[0].references['cmp'];
fixture.detectChanges();
expect(cmp.numberOfChecks).toEqual(1);
@ -699,7 +699,7 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var childComponent =
const childComponent =
fixture.debugElement.children[0].children[0].children[0].references['child'];
expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective);
});
@ -720,9 +720,9 @@ function declareTests({useJit}: {useJit: boolean}) {
fixture.detectChanges();
var tc = fixture.debugElement.children[0].children[0].children[0];
const tc = fixture.debugElement.children[0].children[0].children[0];
var childComponent = tc.references['child'];
const childComponent = tc.references['child'];
expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective);
});
@ -733,12 +733,12 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var tc = fixture.debugElement.children[0];
var emitter = tc.injector.get(DirectiveEmittingEvent);
var listener = tc.injector.get(DirectiveListeningEvent);
const tc = fixture.debugElement.children[0];
const emitter = tc.injector.get(DirectiveEmittingEvent);
const listener = tc.injector.get(DirectiveListeningEvent);
expect(listener.msg).toEqual('');
var eventCount = 0;
let eventCount = 0;
emitter.event.subscribe({
next: () => {
@ -763,11 +763,11 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var tc = fixture.debugElement.childNodes[0];
const tc = fixture.debugElement.childNodes[0];
var emitter = tc.injector.get(DirectiveEmittingEvent);
var myComp = fixture.debugElement.injector.get(MyComp);
var listener = tc.injector.get(DirectiveListeningEvent);
const emitter = tc.injector.get(DirectiveEmittingEvent);
const myComp = fixture.debugElement.injector.get(MyComp);
const listener = tc.injector.get(DirectiveListeningEvent);
myComp.ctxProp = '';
expect(listener.msg).toEqual('');
@ -787,8 +787,8 @@ function declareTests({useJit}: {useJit: boolean}) {
const template = '<div [(control)]="ctxProp" two-way></div>';
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var tc = fixture.debugElement.children[0];
var dir = tc.injector.get(DirectiveWithTwoWayBinding);
const tc = fixture.debugElement.children[0];
const dir = tc.injector.get(DirectiveWithTwoWayBinding);
fixture.componentInstance.ctxProp = 'one';
fixture.detectChanges();
@ -807,8 +807,8 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var tc = fixture.debugElement.children[0];
var listener = tc.injector.get(DirectiveListeningDomEvent);
const tc = fixture.debugElement.children[0];
const listener = tc.injector.get(DirectiveListeningDomEvent);
dispatchEvent(tc.nativeElement, 'domEvent');
@ -828,8 +828,8 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var tc = fixture.debugElement.children[0];
var listener = tc.injector.get(DirectiveListeningDomEvent);
const tc = fixture.debugElement.children[0];
const listener = tc.injector.get(DirectiveListeningDomEvent);
dispatchEvent(getDOM().getGlobalEventTarget('window'), 'domEvent');
expect(listener.eventTypes).toEqual(['window_domEvent']);
@ -874,8 +874,8 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var tc = fixture.debugElement.children[0];
var updateHost = tc.injector.get(DirectiveUpdatingHostProperties);
const tc = fixture.debugElement.children[0];
const updateHost = tc.injector.get(DirectiveUpdatingHostProperties);
updateHost.id = 'newId';
@ -898,7 +898,7 @@ function declareTests({useJit}: {useJit: boolean}) {
.createComponent(MyComp);
fixture.detectChanges();
var tc = fixture.debugElement.children[0];
const tc = fixture.debugElement.children[0];
expect(tc.properties['id']).toBe('one');
expect(tc.properties['title']).toBe(undefined);
});
@ -931,9 +931,9 @@ function declareTests({useJit}: {useJit: boolean}) {
{set: {template: `<div *ngFor="let id of ['forId']" host-listener></div>`}})
.createComponent(MyComp);
fixture.detectChanges();
var tc = fixture.debugElement.children[0];
const tc = fixture.debugElement.children[0];
tc.triggerEventHandler('click', {});
var dir: DirectiveWithHostListener = tc.injector.get(DirectiveWithHostListener);
const dir: DirectiveWithHostListener = tc.injector.get(DirectiveWithHostListener);
expect(dir.receivedArgs).toEqual(['one', undefined]);
});
@ -962,8 +962,8 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var dispatchedEvent = getDOM().createMouseEvent('click');
var dispatchedEvent2 = getDOM().createMouseEvent('click');
const dispatchedEvent = getDOM().createMouseEvent('click');
const dispatchedEvent2 = getDOM().createMouseEvent('click');
getDOM().dispatchEvent(fixture.debugElement.children[0].nativeElement, dispatchedEvent);
getDOM().dispatchEvent(fixture.debugElement.children[1].nativeElement, dispatchedEvent2);
expect(getDOM().isPrevented(dispatchedEvent)).toBe(true);
@ -984,10 +984,10 @@ function declareTests({useJit}: {useJit: boolean}) {
fixture.componentInstance.ctxBoolProp = true;
fixture.detectChanges();
var tc = fixture.debugElement.children[0];
const tc = fixture.debugElement.children[0];
var listener = tc.injector.get(DirectiveListeningDomEvent);
var listenerother = tc.injector.get(DirectiveListeningDomEventOther);
const listener = tc.injector.get(DirectiveListeningDomEvent);
const listenerother = tc.injector.get(DirectiveListeningDomEventOther);
dispatchEvent(getDOM().getGlobalEventTarget('window'), 'domEvent');
expect(listener.eventTypes).toEqual(['window_domEvent']);
expect(listenerother.eventType).toEqual('other_domEvent');
@ -1026,10 +1026,10 @@ function declareTests({useJit}: {useJit: boolean}) {
});
it('should allow to create a ViewContainerRef at any bound location', async(() => {
var fixture = TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]})
.createComponent(MyComp);
var tc = fixture.debugElement.children[0].children[0];
var dynamicVp: DynamicViewport = tc.injector.get(DynamicViewport);
const fixture = TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]})
.createComponent(MyComp);
const tc = fixture.debugElement.children[0].children[0];
const dynamicVp: DynamicViewport = tc.injector.get(DynamicViewport);
dynamicVp.create();
fixture.detectChanges();
expect(fixture.debugElement.children[0].children[1].nativeElement)
@ -1037,10 +1037,10 @@ function declareTests({useJit}: {useJit: boolean}) {
}));
it('should allow to create multiple ViewContainerRef at a location', async(() => {
var fixture = TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]})
.createComponent(MyComp);
var tc = fixture.debugElement.children[0].children[0];
var dynamicVp: DynamicViewport = tc.injector.get(DynamicViewport);
const fixture = TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]})
.createComponent(MyComp);
const tc = fixture.debugElement.children[0].children[0];
const dynamicVp: DynamicViewport = tc.injector.get(DynamicViewport);
dynamicVp.create();
dynamicVp.create();
fixture.detectChanges();
@ -1057,8 +1057,8 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var tc = fixture.debugElement.children[0];
var needsAttribute = tc.injector.get(NeedsAttribute);
const tc = fixture.debugElement.children[0];
const needsAttribute = tc.injector.get(NeedsAttribute);
expect(needsAttribute.typeAttribute).toEqual('text');
expect(needsAttribute.staticAttribute).toEqual('');
expect(needsAttribute.fooAttribute).toEqual(null);
@ -1101,7 +1101,7 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var comp = fixture.debugElement.children[0].children[0].references['consuming'];
const comp = fixture.debugElement.children[0].children[0].references['consuming'];
expect(comp.injectable).toBeAnInstanceOf(InjectableService);
});
@ -1117,7 +1117,7 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(DirectiveProvidingInjectableInView, {set: {template}});
const fixture = TestBed.createComponent(DirectiveProvidingInjectableInView);
var comp = fixture.debugElement.children[0].references['consuming'];
const comp = fixture.debugElement.children[0].references['consuming'];
expect(comp.injectable).toBeAnInstanceOf(InjectableService);
});
@ -1145,7 +1145,7 @@ function declareTests({useJit}: {useJit: boolean}) {
});
const fixture = TestBed.createComponent(MyComp);
var comp = fixture.debugElement.children[0].children[0].references['dir'];
const comp = fixture.debugElement.children[0].children[0].references['dir'];
expect(comp.directive.injectable).toBeAnInstanceOf(InjectableService);
});
@ -1167,13 +1167,13 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var gpComp = fixture.debugElement.children[0];
var parentComp = gpComp.children[0];
var childComp = parentComp.children[0];
const gpComp = fixture.debugElement.children[0];
const parentComp = gpComp.children[0];
const childComp = parentComp.children[0];
var grandParent = gpComp.injector.get(GrandParentProvidingEventBus);
var parent = parentComp.injector.get(ParentProvidingEventBus);
var child = childComp.injector.get(ChildConsumingEventBus);
const grandParent = gpComp.injector.get(GrandParentProvidingEventBus);
const parent = parentComp.injector.get(ParentProvidingEventBus);
const child = childComp.injector.get(ChildConsumingEventBus);
expect(grandParent.bus.name).toEqual('grandparent');
expect(parent.bus.name).toEqual('parent');
@ -1195,7 +1195,7 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var providing = fixture.debugElement.children[0].references['providing'];
const providing = fixture.debugElement.children[0].references['providing'];
expect(providing.created).toBe(false);
fixture.componentInstance.ctxBoolProp = true;
@ -1295,7 +1295,7 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.createComponent(MyComp);
throw 'Should throw';
} catch (e) {
var c = e.context;
const c = e.context;
expect(getDOM().nodeName(c.componentRenderElement).toUpperCase()).toEqual('DIV');
expect((<Injector>c.injector).get).toBeTruthy();
}
@ -1310,7 +1310,7 @@ function declareTests({useJit}: {useJit: boolean}) {
fixture.detectChanges();
throw 'Should throw';
} catch (e) {
var c = e.context;
const c = e.context;
expect(getDOM().nodeName(c.renderNode).toUpperCase()).toEqual('INPUT');
expect(getDOM().nodeName(c.componentRenderElement).toUpperCase()).toEqual('DIV');
expect((<Injector>c.injector).get).toBeTruthy();
@ -1330,7 +1330,7 @@ function declareTests({useJit}: {useJit: boolean}) {
fixture.detectChanges();
throw 'Should throw';
} catch (e) {
var c = e.context;
const c = e.context;
expect(c.renderNode).toBeTruthy();
expect(c.source).toContain(':0:5');
}
@ -1348,12 +1348,12 @@ function declareTests({useJit}: {useJit: boolean}) {
const fixture = TestBed.createComponent(MyComp);
tick();
var tc = fixture.debugElement.children[0];
const tc = fixture.debugElement.children[0];
try {
tc.injector.get(DirectiveEmittingEvent).fireEvent('boom');
} catch (e) {
var c = e.context;
const c = e.context;
expect(getDOM().nodeName(c.renderNode).toUpperCase()).toEqual('SPAN');
expect(getDOM().nodeName(c.componentRenderElement).toUpperCase()).toEqual('DIV');
expect((<Injector>c.injector).get).toBeTruthy();
@ -1457,7 +1457,7 @@ function declareTests({useJit}: {useJit: boolean}) {
fixture.componentInstance.ctxProp = 'TITLE';
fixture.detectChanges();
var el = getDOM().querySelector(fixture.nativeElement, 'span');
const el = getDOM().querySelector(fixture.nativeElement, 'span');
expect(isBlank(el.title) || el.title == '').toBeTruthy();
});
@ -1470,7 +1470,7 @@ function declareTests({useJit}: {useJit: boolean}) {
fixture.componentInstance.ctxProp = 'TITLE';
fixture.detectChanges();
var el = getDOM().querySelector(fixture.nativeElement, 'span');
const el = getDOM().querySelector(fixture.nativeElement, 'span');
expect(el.title).toEqual('TITLE');
});
});
@ -1526,7 +1526,7 @@ function declareTests({useJit}: {useJit: boolean}) {
const fixture = TestBed.createComponent(MyComp);
fixture.detectChanges();
var dir = fixture.debugElement.children[0].injector.get(DirectiveWithPropDecorators);
const dir = fixture.debugElement.children[0].injector.get(DirectiveWithPropDecorators);
expect(dir.dirProp).toEqual('aaa');
});
@ -1540,7 +1540,7 @@ function declareTests({useJit}: {useJit: boolean}) {
const fixture = TestBed.createComponent(MyComp);
fixture.detectChanges();
var dir = fixture.debugElement.children[0].injector.get(DirectiveWithPropDecorators);
const dir = fixture.debugElement.children[0].injector.get(DirectiveWithPropDecorators);
dir.myAttr = 'aaa';
fixture.detectChanges();
@ -1560,7 +1560,7 @@ function declareTests({useJit}: {useJit: boolean}) {
tick();
var emitter =
const emitter =
fixture.debugElement.children[0].injector.get(DirectiveWithPropDecorators);
emitter.fireEvent('fired !');
@ -1580,8 +1580,8 @@ function declareTests({useJit}: {useJit: boolean}) {
const fixture = TestBed.createComponent(MyComp);
fixture.detectChanges();
var dir = fixture.debugElement.children[0].injector.get(DirectiveWithPropDecorators);
var native = fixture.debugElement.children[0].nativeElement;
const dir = fixture.debugElement.children[0].injector.get(DirectiveWithPropDecorators);
const native = fixture.debugElement.children[0].nativeElement;
getDOM().dispatchEvent(native, getDOM().createMouseEvent('click'));
expect(dir.target).toBe(native);
@ -1599,7 +1599,7 @@ function declareTests({useJit}: {useJit: boolean}) {
const fixture = TestBed.createComponent(MyComp);
fixture.detectChanges();
var native = fixture.debugElement.children[0].nativeElement;
const native = fixture.debugElement.children[0].nativeElement;
expect(native).toHaveText('No View Decorator: 123');
});
});
@ -1613,15 +1613,15 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var el = fixture.nativeElement;
var svg = getDOM().childNodes(el)[0];
var use = getDOM().childNodes(svg)[0];
const el = fixture.nativeElement;
const svg = getDOM().childNodes(el)[0];
const use = getDOM().childNodes(svg)[0];
expect(getDOM().getProperty(<Element>svg, 'namespaceURI'))
.toEqual('http://www.w3.org/2000/svg');
expect(getDOM().getProperty(<Element>use, 'namespaceURI'))
.toEqual('http://www.w3.org/2000/svg');
var firstAttribute = getDOM().getProperty(<Element>use, 'attributes')[0];
const firstAttribute = getDOM().getProperty(<Element>use, 'attributes')[0];
expect(firstAttribute.name).toEqual('xlink:href');
expect(firstAttribute.namespaceURI).toEqual('http://www.w3.org/1999/xlink');
});
@ -1633,10 +1633,10 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
var el = fixture.nativeElement;
var svg = getDOM().childNodes(el)[0];
var foreignObject = getDOM().childNodes(svg)[0];
var p = getDOM().childNodes(foreignObject)[0];
const el = fixture.nativeElement;
const svg = getDOM().childNodes(el)[0];
const foreignObject = getDOM().childNodes(svg)[0];
const p = getDOM().childNodes(foreignObject)[0];
expect(getDOM().getProperty(<Element>svg, 'namespaceURI'))
.toEqual('http://www.w3.org/2000/svg');
expect(getDOM().getProperty(<Element>foreignObject, 'namespaceURI'))
@ -1654,7 +1654,7 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(SomeCmp, {set: {template}});
const fixture = TestBed.createComponent(SomeCmp);
let useEl = getDOM().firstChild(fixture.nativeElement);
const useEl = getDOM().firstChild(fixture.nativeElement);
expect(getDOM().getAttributeNS(useEl, 'http://www.w3.org/1999/xlink', 'href'))
.toEqual('#id');
});
@ -1665,8 +1665,8 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(SomeCmp, {set: {template}});
const fixture = TestBed.createComponent(SomeCmp);
let cmp = fixture.componentInstance;
let useEl = getDOM().firstChild(fixture.nativeElement);
const cmp = fixture.componentInstance;
const useEl = getDOM().firstChild(fixture.nativeElement);
cmp.value = '#id';
fixture.detectChanges();
@ -1721,7 +1721,7 @@ class SimpleImperativeViewComponent {
done: any;
constructor(self: ElementRef, renderer: Renderer) {
var hostElement = self.nativeElement;
const hostElement = self.nativeElement;
getDOM().appendChild(hostElement, el('hello imp view'));
}
}
@ -1731,7 +1731,7 @@ class DynamicViewport {
private componentFactory: ComponentFactory<ChildCompUsingService>;
private injector: Injector;
constructor(private vc: ViewContainerRef, componentFactoryResolver: ComponentFactoryResolver) {
var myService = new MyService();
const myService = new MyService();
myService.greeting = 'dynamic greet';
this.injector = ReflectiveInjector.resolveAndCreate(
@ -1988,7 +1988,7 @@ class DirectiveListeningDomEvent {
onBodyEvent(eventType: string) { this.eventTypes.push('body_' + eventType); }
}
var globalCounter = 0;
let globalCounter = 0;
@Directive({selector: '[listenerother]', host: {'(window:domEvent)': 'onEvent($event.type)'}})
class DirectiveListeningDomEventOther {
eventType: string;
@ -2222,8 +2222,8 @@ class SomeImperativeViewport {
}
if (value) {
this.view = this.vc.createEmbeddedView(this.templateRef);
var nodes = this.view.rootNodes;
for (var i = 0; i < nodes.length; i++) {
const nodes = this.view.rootNodes;
for (let i = 0; i < nodes.length; i++) {
getDOM().appendChild(this.anchor, nodes[i]);
}
}

View File

@ -126,7 +126,7 @@ function declareTests({useJit}: {useJit: boolean}) {
const fixture = TestBed.createComponent(MyComp);
fixture.detectChanges();
var q = fixture.debugElement.children[0].references['q'];
const q = fixture.debugElement.children[0].references['q'];
fixture.detectChanges();
expect(q.textDirChildren.length).toEqual(1);
@ -139,7 +139,7 @@ function declareTests({useJit}: {useJit: boolean}) {
const fixture = TestBed.createComponent(MyComp);
fixture.detectChanges();
var q = fixture.debugElement.children[0].references['q'];
const q = fixture.debugElement.children[0].references['q'];
fixture.detectChanges();
expect(q.textDirChildren.length).toEqual(1);

View File

@ -109,9 +109,9 @@ export function main() {
function declareTests({useJit}: {useJit: boolean}) {
describe('NgModule', () => {
var compiler: Compiler;
var injector: Injector;
var console: DummyConsole;
let compiler: Compiler;
let injector: Injector;
let console: DummyConsole;
beforeEach(() => {
console = new DummyConsole();
@ -129,8 +129,8 @@ function declareTests({useJit}: {useJit: boolean}) {
}
function createComp<T>(compType: Type<T>, moduleType: Type<any>): ComponentFixture<T> {
let ngModule = createModule(moduleType);
var cf = ngModule.componentFactoryResolver.resolveComponentFactory(compType);
const ngModule = createModule(moduleType);
const cf = ngModule.componentFactoryResolver.resolveComponentFactory(compType);
return new ComponentFixture(cf.create(injector), null, false);
}
@ -268,7 +268,7 @@ function declareTests({useJit}: {useJit: boolean}) {
it('should register loaded modules', () => {
createModule(SomeModule);
let factory = getModuleFactory(token);
const factory = getModuleFactory(token);
expect(factory).toBeTruthy();
expect(factory.moduleType).toBe(SomeModule);
});
@ -613,23 +613,23 @@ function declareTests({useJit}: {useJit: boolean}) {
() => { expect(createInjector([]).get(moduleType)).toBeAnInstanceOf(moduleType); });
it('should instantiate a class without dependencies', () => {
var injector = createInjector([Engine]);
var engine = injector.get(Engine);
const injector = createInjector([Engine]);
const engine = injector.get(Engine);
expect(engine).toBeAnInstanceOf(Engine);
});
it('should resolve dependencies based on type information', () => {
var injector = createInjector([Engine, Car]);
var car = injector.get(Car);
const injector = createInjector([Engine, Car]);
const car = injector.get(Car);
expect(car).toBeAnInstanceOf(Car);
expect(car.engine).toBeAnInstanceOf(Engine);
});
it('should resolve dependencies based on @Inject annotation', () => {
var injector = createInjector([TurboEngine, Engine, CarWithInject]);
var car = injector.get(CarWithInject);
const injector = createInjector([TurboEngine, Engine, CarWithInject]);
const car = injector.get(CarWithInject);
expect(car).toBeAnInstanceOf(CarWithInject);
expect(car.engine).toBeAnInstanceOf(TurboEngine);
@ -646,79 +646,79 @@ function declareTests({useJit}: {useJit: boolean}) {
});
it('should cache instances', () => {
var injector = createInjector([Engine]);
const injector = createInjector([Engine]);
var e1 = injector.get(Engine);
var e2 = injector.get(Engine);
const e1 = injector.get(Engine);
const e2 = injector.get(Engine);
expect(e1).toBe(e2);
});
it('should provide to a value', () => {
var injector = createInjector([{provide: Engine, useValue: 'fake engine'}]);
const injector = createInjector([{provide: Engine, useValue: 'fake engine'}]);
var engine = injector.get(Engine);
const engine = injector.get(Engine);
expect(engine).toEqual('fake engine');
});
it('should provide to a factory', () => {
function sportsCarFactory(e: Engine) { return new SportsCar(e); }
var injector =
const injector =
createInjector([Engine, {provide: Car, useFactory: sportsCarFactory, deps: [Engine]}]);
var car = injector.get(Car);
const car = injector.get(Car);
expect(car).toBeAnInstanceOf(SportsCar);
expect(car.engine).toBeAnInstanceOf(Engine);
});
it('should supporting provider to null', () => {
var injector = createInjector([{provide: Engine, useValue: null}]);
var engine = injector.get(Engine);
const injector = createInjector([{provide: Engine, useValue: null}]);
const engine = injector.get(Engine);
expect(engine).toBeNull();
});
it('should provide to an alias', () => {
var injector = createInjector([
const injector = createInjector([
Engine, {provide: SportsCar, useClass: SportsCar},
{provide: Car, useExisting: SportsCar}
]);
var car = injector.get(Car);
var sportsCar = injector.get(SportsCar);
const car = injector.get(Car);
const sportsCar = injector.get(SportsCar);
expect(car).toBeAnInstanceOf(SportsCar);
expect(car).toBe(sportsCar);
});
it('should support multiProviders', () => {
var injector = createInjector([
const injector = createInjector([
Engine, {provide: Car, useClass: SportsCar, multi: true},
{provide: Car, useClass: CarWithOptionalEngine, multi: true}
]);
var cars = injector.get(Car);
const cars = injector.get(Car);
expect(cars.length).toEqual(2);
expect(cars[0]).toBeAnInstanceOf(SportsCar);
expect(cars[1]).toBeAnInstanceOf(CarWithOptionalEngine);
});
it('should support multiProviders that are created using useExisting', () => {
var injector = createInjector(
const injector = createInjector(
[Engine, SportsCar, {provide: Car, useExisting: SportsCar, multi: true}]);
var cars = injector.get(Car);
const cars = injector.get(Car);
expect(cars.length).toEqual(1);
expect(cars[0]).toBe(injector.get(SportsCar));
});
it('should throw when the aliased provider does not exist', () => {
var injector = createInjector([{provide: 'car', useExisting: SportsCar}]);
var e = `No provider for ${stringify(SportsCar)}!`;
const injector = createInjector([{provide: 'car', useExisting: SportsCar}]);
const e = `No provider for ${stringify(SportsCar)}!`;
expect(() => injector.get('car')).toThrowError(e);
});
it('should handle forwardRef in useExisting', () => {
var injector = createInjector([
const injector = createInjector([
{provide: 'originalEngine', useClass: forwardRef(() => Engine)},
{provide: 'aliasedEngine', useExisting: <any>forwardRef(() => 'originalEngine')}
]);
@ -726,37 +726,37 @@ function declareTests({useJit}: {useJit: boolean}) {
});
it('should support overriding factory dependencies', () => {
var injector = createInjector(
const injector = createInjector(
[Engine, {provide: Car, useFactory: (e: Engine) => new SportsCar(e), deps: [Engine]}]);
var car = injector.get(Car);
const car = injector.get(Car);
expect(car).toBeAnInstanceOf(SportsCar);
expect(car.engine).toBeAnInstanceOf(Engine);
});
it('should support optional dependencies', () => {
var injector = createInjector([CarWithOptionalEngine]);
const injector = createInjector([CarWithOptionalEngine]);
var car = injector.get(CarWithOptionalEngine);
const car = injector.get(CarWithOptionalEngine);
expect(car.engine).toEqual(null);
});
it('should flatten passed-in providers', () => {
var injector = createInjector([[[Engine, Car]]]);
const injector = createInjector([[[Engine, Car]]]);
var car = injector.get(Car);
const car = injector.get(Car);
expect(car).toBeAnInstanceOf(Car);
});
it('should use the last provider when there are multiple providers for same token', () => {
var injector = createInjector(
const injector = createInjector(
[{provide: Engine, useClass: Engine}, {provide: Engine, useClass: TurboEngine}]);
expect(injector.get(Engine)).toBeAnInstanceOf(TurboEngine);
});
it('should use non-type tokens', () => {
var injector = createInjector([{provide: 'token', useValue: 'value'}]);
const injector = createInjector([{provide: 'token', useValue: 'value'}]);
expect(injector.get('token')).toEqual('value');
});
@ -774,14 +774,14 @@ function declareTests({useJit}: {useJit: boolean}) {
});
it('should provide itself', () => {
var parent = createInjector([]);
var child = createInjector([], parent);
const parent = createInjector([]);
const child = createInjector([], parent);
expect(child.get(Injector)).toBe(child);
});
it('should throw when no provider defined', () => {
var injector = createInjector([]);
const injector = createInjector([]);
expect(() => injector.get('NonExisting')).toThrowError('No provider for NonExisting!');
});
@ -791,37 +791,37 @@ function declareTests({useJit}: {useJit: boolean}) {
});
it('should support null values', () => {
var injector = createInjector([{provide: 'null', useValue: null}]);
const injector = createInjector([{provide: 'null', useValue: null}]);
expect(injector.get('null')).toBe(null);
});
describe('child', () => {
it('should load instances from parent injector', () => {
var parent = createInjector([Engine]);
var child = createInjector([], parent);
const parent = createInjector([Engine]);
const child = createInjector([], parent);
var engineFromParent = parent.get(Engine);
var engineFromChild = child.get(Engine);
const engineFromParent = parent.get(Engine);
const engineFromChild = child.get(Engine);
expect(engineFromChild).toBe(engineFromParent);
});
it('should not use the child providers when resolving the dependencies of a parent provider',
() => {
var parent = createInjector([Car, Engine]);
var child = createInjector([{provide: Engine, useClass: TurboEngine}], parent);
const parent = createInjector([Car, Engine]);
const child = createInjector([{provide: Engine, useClass: TurboEngine}], parent);
var carFromChild = child.get(Car);
const carFromChild = child.get(Car);
expect(carFromChild.engine).toBeAnInstanceOf(Engine);
});
it('should create new instance in a child injector', () => {
var parent = createInjector([Engine]);
var child = createInjector([{provide: Engine, useClass: TurboEngine}], parent);
const parent = createInjector([Engine]);
const child = createInjector([{provide: Engine, useClass: TurboEngine}], parent);
var engineFromParent = parent.get(Engine);
var engineFromChild = child.get(Engine);
const engineFromParent = parent.get(Engine);
const engineFromChild = child.get(Engine);
expect(engineFromParent).not.toBe(engineFromChild);
expect(engineFromChild).toBeAnInstanceOf(TurboEngine);
@ -832,7 +832,7 @@ function declareTests({useJit}: {useJit: boolean}) {
describe('depedency resolution', () => {
describe('@Self()', () => {
it('should return a dependency from self', () => {
var inj = createInjector([
const inj = createInjector([
Engine,
{provide: Car, useFactory: (e: Engine) => new Car(e), deps: [[Engine, new Self()]]}
]);
@ -852,8 +852,8 @@ function declareTests({useJit}: {useJit: boolean}) {
describe('default', () => {
it('should not skip self', () => {
var parent = createInjector([Engine]);
var child = createInjector(
const parent = createInjector([Engine]);
const child = createInjector(
[
{provide: Engine, useClass: TurboEngine},
{provide: Car, useFactory: (e: Engine) => new Car(e), deps: [Engine]}

View File

@ -126,9 +126,9 @@ export function main() {
});
const main = TestBed.createComponent(MainComp);
var viewportDirectives = main.debugElement.children[0]
.childNodes.filter(By.directive(ManualViewportDirective))
.map(de => de.injector.get(ManualViewportDirective));
const viewportDirectives = main.debugElement.children[0]
.childNodes.filter(By.directive(ManualViewportDirective))
.map(de => de.injector.get(ManualViewportDirective));
expect(main.nativeElement).toHaveText('(, B)');
viewportDirectives.forEach(d => d.show());
@ -170,7 +170,7 @@ export function main() {
});
const main = TestBed.createComponent(MainComp);
var viewportDirective =
const viewportDirective =
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
ManualViewportDirective);
@ -194,7 +194,7 @@ export function main() {
});
const main = TestBed.createComponent(MainComp);
var viewportDirective =
const viewportDirective =
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
ManualViewportDirective);
@ -254,7 +254,7 @@ export function main() {
});
const main = TestBed.createComponent(MainComp);
var projectDirective: ProjectDirective =
const projectDirective: ProjectDirective =
main.debugElement.queryAllNodes(By.directive(ProjectDirective))[0].injector.get(
ProjectDirective);
@ -275,10 +275,10 @@ export function main() {
});
const main = TestBed.createComponent(MainComp);
var sourceDirective: ManualViewportDirective =
const sourceDirective: ManualViewportDirective =
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
ManualViewportDirective);
var projectDirective: ProjectDirective =
const projectDirective: ProjectDirective =
main.debugElement.queryAllNodes(By.directive(ProjectDirective))[0].injector.get(
ProjectDirective);
expect(main.nativeElement).toHaveText('SIMPLE()START()END');
@ -301,10 +301,10 @@ export function main() {
});
const main = TestBed.createComponent(MainComp);
var sourceDirective: ManualViewportDirective =
const sourceDirective: ManualViewportDirective =
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
ManualViewportDirective);
var projectDirective: ProjectDirective =
const projectDirective: ProjectDirective =
main.debugElement.queryAllNodes(By.directive(ProjectDirective))[0].injector.get(
ProjectDirective);
expect(main.nativeElement).toHaveText('(, B)START()END');
@ -327,7 +327,7 @@ export function main() {
const main = TestBed.createComponent(MainComp);
main.detectChanges();
var manualDirective: ManualViewportDirective =
const manualDirective: ManualViewportDirective =
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
ManualViewportDirective);
expect(main.nativeElement).toHaveText('TREE(0:)');
@ -350,14 +350,14 @@ export function main() {
expect(main.nativeElement).toHaveText('TREE(0:)');
var tree = main.debugElement.query(By.directive(Tree));
var manualDirective: ManualViewportDirective = tree.queryAllNodes(By.directive(
const tree = main.debugElement.query(By.directive(Tree));
let manualDirective: ManualViewportDirective = tree.queryAllNodes(By.directive(
ManualViewportDirective))[0].injector.get(ManualViewportDirective);
manualDirective.show();
main.detectChanges();
expect(main.nativeElement).toHaveText('TREE(0:TREE2(1:))');
var tree2 = main.debugElement.query(By.directive(Tree2));
const tree2 = main.debugElement.query(By.directive(Tree2));
manualDirective = tree2.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
ManualViewportDirective);
manualDirective.show();
@ -376,7 +376,7 @@ export function main() {
});
const main = TestBed.createComponent(MainComp);
var childNodes = getDOM().childNodes(main.nativeElement);
const childNodes = getDOM().childNodes(main.nativeElement);
expect(childNodes[0]).toHaveText('div {color: red}SIMPLE1(A)');
expect(childNodes[1]).toHaveText('div {color: blue}SIMPLE2(B)');
main.destroy();
@ -395,9 +395,9 @@ export function main() {
});
const main = TestBed.createComponent(MainComp);
var mainEl = main.nativeElement;
var div1 = getDOM().firstChild(mainEl);
var div2 = getDOM().createElement('div');
const mainEl = main.nativeElement;
const div1 = getDOM().firstChild(mainEl);
const div2 = getDOM().createElement('div');
getDOM().setAttribute(div2, 'class', 'redStyle');
getDOM().appendChild(mainEl, div2);
expect(getDOM().getComputedStyle(div1).color).toEqual('rgb(255, 0, 0)');
@ -415,9 +415,9 @@ export function main() {
});
const main = TestBed.createComponent(MainComp);
var mainEl = main.nativeElement;
var div1 = getDOM().firstChild(mainEl);
var div2 = getDOM().createElement('div');
const mainEl = main.nativeElement;
const div1 = getDOM().firstChild(mainEl);
const div2 = getDOM().createElement('div');
getDOM().appendChild(mainEl, div2);
expect(getDOM().getComputedStyle(div1).color).toEqual('rgb(255, 0, 0)');
expect(getDOM().getComputedStyle(div2).color).toEqual('rgb(0, 0, 0)');
@ -433,7 +433,7 @@ export function main() {
expect(main.nativeElement).toHaveText('MAIN()');
var viewportElement =
let viewportElement =
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0];
viewportElement.injector.get(ManualViewportDirective).show();
expect(main.nativeElement).toHaveText('MAIN(FIRST())');
@ -483,9 +483,9 @@ export function main() {
});
const main = TestBed.createComponent(MainComp);
var conditionalComp = main.debugElement.query(By.directive(ConditionalContentComponent));
const conditionalComp = main.debugElement.query(By.directive(ConditionalContentComponent));
var viewViewportDir =
const viewViewportDir =
conditionalComp.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
ManualViewportDirective);
@ -496,7 +496,7 @@ export function main() {
expect(main.nativeElement).toHaveText('(AC, D)');
var contentViewportDir =
const contentViewportDir =
conditionalComp.queryAllNodes(By.directive(ManualViewportDirective))[1].injector.get(
ManualViewportDirective);

View File

@ -15,8 +15,8 @@ import {iterateListLike} from '../../src/facade/collection';
export function main() {
describe('QueryList', () => {
var queryList: QueryList<string>;
var log: string;
let queryList: QueryList<string>;
let log: string;
beforeEach(() => {
queryList = new QueryList<string>();
log = '';
@ -103,7 +103,7 @@ export function main() {
it('should support toString', () => {
queryList.reset(['one', 'two']);
var listString = queryList.toString();
const listString = queryList.toString();
expect(listString.indexOf('one') != -1).toBeTruthy();
expect(listString.indexOf('two') != -1).toBeTruthy();
});
@ -123,7 +123,7 @@ export function main() {
if (getDOM().supportsDOMEvents()) {
describe('simple observable interface', () => {
it('should fire callbacks on change', fakeAsync(() => {
var fires = 0;
let fires = 0;
queryList.changes.subscribe({next: (_) => { fires += 1; }});
queryList.notifyOnChanges();
@ -138,7 +138,7 @@ export function main() {
}));
it('should provides query list as an argument', fakeAsync(() => {
var recorded: any /** TODO #9100 */;
let recorded: any /** TODO #9100 */;
queryList.changes.subscribe({next: (v: any) => { recorded = v; }});
queryList.reset(['one']);

View File

@ -106,33 +106,33 @@ function declareTests({useJit}: {useJit: boolean}) {
}
it('should support providers with an OpaqueToken that contains a `.` in the name', () => {
var token = new OpaqueToken('a.b');
var tokenValue = 1;
const token = new OpaqueToken('a.b');
const tokenValue = 1;
const injector = createInjector([{provide: token, useValue: tokenValue}]);
expect(injector.get(token)).toEqual(tokenValue);
});
it('should support providers with string token with a `.` in it', () => {
var token = 'a.b';
var tokenValue = 1;
const token = 'a.b';
const tokenValue = 1;
const injector = createInjector([{provide: token, useValue: tokenValue}]);
expect(injector.get(token)).toEqual(tokenValue);
});
it('should support providers with an anonymous function', () => {
var token = () => true;
var tokenValue = 1;
const token = () => true;
const tokenValue = 1;
const injector = createInjector([{provide: token, useValue: tokenValue}]);
expect(injector.get(token)).toEqual(tokenValue);
});
it('should support providers with an OpaqueToken that has a StringMap as value', () => {
var token1 = new OpaqueToken('someToken');
var token2 = new OpaqueToken('someToken');
var tokenValue1 = {'a': 1};
var tokenValue2 = {'a': 1};
const token1 = new OpaqueToken('someToken');
const token2 = new OpaqueToken('someToken');
const tokenValue1 = {'a': 1};
const tokenValue2 = {'a': 1};
const injector = createInjector(
[{provide: token1, useValue: tokenValue1}, {provide: token2, useValue: tokenValue2}]);

View File

@ -97,9 +97,9 @@ function declareTests({useJit}: {useJit: boolean}) {
const fixture = TestBed.createComponent(SecuredComponent);
const sanitizer: DomSanitizer = getTestBed().get(DomSanitizer);
let e = fixture.debugElement.children[0].nativeElement;
let ci = fixture.componentInstance;
let trusted = sanitizer.bypassSecurityTrustUrl('javascript:alert(1)');
const e = fixture.debugElement.children[0].nativeElement;
const ci = fixture.componentInstance;
const trusted = sanitizer.bypassSecurityTrustUrl('javascript:alert(1)');
ci.ctxProp = trusted;
fixture.detectChanges();
expect(getDOM().getProperty(e, 'href')).toEqual('javascript:alert(1)');
@ -111,8 +111,8 @@ function declareTests({useJit}: {useJit: boolean}) {
const fixture = TestBed.createComponent(SecuredComponent);
const sanitizer: DomSanitizer = getTestBed().get(DomSanitizer);
let trusted = sanitizer.bypassSecurityTrustScript('javascript:alert(1)');
let ci = fixture.componentInstance;
const trusted = sanitizer.bypassSecurityTrustScript('javascript:alert(1)');
const ci = fixture.componentInstance;
ci.ctxProp = trusted;
expect(() => fixture.detectChanges()).toThrowError(/Required a safe URL, got a Script/);
});
@ -123,9 +123,9 @@ function declareTests({useJit}: {useJit: boolean}) {
const fixture = TestBed.createComponent(SecuredComponent);
const sanitizer: DomSanitizer = getTestBed().get(DomSanitizer);
let e = fixture.debugElement.children[0].nativeElement;
let trusted = sanitizer.bypassSecurityTrustUrl('bar/baz');
let ci = fixture.componentInstance;
const e = fixture.debugElement.children[0].nativeElement;
const trusted = sanitizer.bypassSecurityTrustUrl('bar/baz');
const ci = fixture.componentInstance;
ci.ctxProp = trusted;
fixture.detectChanges();
expect(getDOM().getProperty(e, 'href')).toMatch(/SafeValue(%20| )must(%20| )use/);
@ -134,8 +134,8 @@ function declareTests({useJit}: {useJit: boolean}) {
describe('sanitizing', () => {
function checkEscapeOfHrefProperty(fixture: ComponentFixture<any>, isAttribute: boolean) {
let e = fixture.debugElement.children[0].nativeElement;
let ci = fixture.componentInstance;
const e = fixture.debugElement.children[0].nativeElement;
const ci = fixture.componentInstance;
ci.ctxProp = 'hello';
fixture.detectChanges();
// In the browser, reading href returns an absolute URL. On the server side,
@ -201,8 +201,8 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(SecuredComponent, {set: {template}});
const fixture = TestBed.createComponent(SecuredComponent);
let e = fixture.debugElement.children[0].nativeElement;
let ci = fixture.componentInstance;
const e = fixture.debugElement.children[0].nativeElement;
const ci = fixture.componentInstance;
// Make sure binding harmless values works.
ci.ctxProp = 'red';
fixture.detectChanges();
@ -229,8 +229,8 @@ function declareTests({useJit}: {useJit: boolean}) {
TestBed.overrideComponent(SecuredComponent, {set: {template}});
const fixture = TestBed.createComponent(SecuredComponent);
let e = fixture.debugElement.children[0].nativeElement;
let ci = fixture.componentInstance;
const e = fixture.debugElement.children[0].nativeElement;
const ci = fixture.componentInstance;
// Make sure binding harmless values works.
ci.ctxProp = 'some <p>text</p>';
fixture.detectChanges();

View File

@ -34,17 +34,17 @@ export function main() {
afterEach(() => { (global as any).System = oldSystem; });
it('loads a default factory by appending the factory suffix', async(() => {
let loader = new SystemJsNgModuleLoader(new Compiler());
const loader = new SystemJsNgModuleLoader(new Compiler());
loader.load('test').then(contents => { expect(contents).toBe('test module factory'); });
}));
it('loads a named factory by appending the factory suffix', async(() => {
let loader = new SystemJsNgModuleLoader(new Compiler());
const loader = new SystemJsNgModuleLoader(new Compiler());
loader.load('test#Named').then(contents => {
expect(contents).toBe('test NamedNgFactory');
});
}));
it('loads a named factory with a configured prefix and suffix', async(() => {
let loader = new SystemJsNgModuleLoader(new Compiler(), {
const loader = new SystemJsNgModuleLoader(new Compiler(), {
factoryPathPrefix: 'prefixed/',
factoryPathSuffix: '/suffixed',
});

View File

@ -228,7 +228,7 @@ export function main() {
TestBed.configureTestingModule({declarations: [SimpleDirective, NeedsDirective]});
const el = createComponent('<div simpleDirective needsDirective>');
var d = el.children[0].injector.get(NeedsDirective);
const d = el.children[0].injector.get(NeedsDirective);
expect(d).toBeAnInstanceOf(NeedsDirective);
expect(d.dependency).toBeAnInstanceOf(SimpleDirective);
@ -286,7 +286,7 @@ export function main() {
}
];
TestBed.overrideDirective(SimpleDirective, {add: {providers}});
var el = createComponent('<div simpleDirective></div>');
const el = createComponent('<div simpleDirective></div>');
expect(el.children[0].injector.get('injectable2')).toEqual('injectable1-injectable2');
});