cleanup(router): enable noImplicitAny and noImplicntReturns

This commit is contained in:
vsavkin
2016-06-15 16:45:19 -07:00
parent cdbf67ee05
commit 4450e7b246
15 changed files with 154 additions and 133 deletions

View File

@ -8,7 +8,7 @@ describe('applyRedirects', () => {
it("should return the same url tree when no redirects", () => {
checkRedirect([
{path: 'a', component: ComponentA, children: [{path: 'b', component: ComponentB}]}
], "/a/b", t => {
], "/a/b", (t:UrlTree) => {
compareTrees(t, tree('/a/b'));
});
});
@ -17,7 +17,7 @@ describe('applyRedirects', () => {
checkRedirect([
{path: 'a/b', redirectTo: 'a/b/c'},
{path: '**', component: ComponentC}
], "/a/b", t => {
], "/a/b", (t:UrlTree) => {
compareTrees(t, tree('/a/b/c'));
});
});
@ -26,7 +26,7 @@ describe('applyRedirects', () => {
checkRedirect([
{path: 'a/:aid/b/:bid', redirectTo: 'newa/:aid/newb/:bid'},
{path: '**', component: ComponentC}
], "/a/1/b/2", t => {
], "/a/1/b/2", (t:UrlTree) => {
compareTrees(t, tree('/newa/1/newb/2'));
});
});
@ -43,7 +43,7 @@ describe('applyRedirects', () => {
checkRedirect([
{path: 'a/:id', redirectTo: 'd/a/:id/e'},
{path: '**', component: ComponentC}
], "/a;p1=1/1;p2=2", t => {
], "/a;p1=1/1;p2=2", (t:UrlTree) => {
compareTrees(t, tree('/d/a;p1=1/1;p2=2/e'));
});
});
@ -53,7 +53,7 @@ describe('applyRedirects', () => {
{path: 'a/:id', redirectTo: 'd/a/:id/e'},
{path: 'c/d', component: ComponentA, outlet: 'aux'},
{path: '**', component: ComponentC}
], "/a/1(aux:c/d)", t => {
], "/a/1(aux:c/d)", (t:UrlTree) => {
compareTrees(t, tree('/d/a/1/e(aux:c/d)'));
});
});
@ -63,7 +63,7 @@ describe('applyRedirects', () => {
{path: 'a/:id', component: ComponentA},
{path: 'c/d', redirectTo: 'f/c/d/e', outlet: 'aux'},
{path: '**', component: ComponentC, outlet: 'aux'}
], "/a/1(aux:c/d)", t => {
], "/a/1(aux:c/d)", (t:UrlTree) => {
compareTrees(t, tree('/a/1(aux:f/c/d/e)'));
});
});
@ -74,7 +74,7 @@ describe('applyRedirects', () => {
{path: 'b', component: ComponentB},
]},
{path: 'c', redirectTo: 'a'}
], "c/b", t => {
], "c/b", (t:UrlTree) => {
compareTrees(t, tree('a/b'));
});
});
@ -85,7 +85,7 @@ describe('applyRedirects', () => {
{path: 'b', component: ComponentB},
]},
{path: '', redirectTo: 'a'}
], "b", t => {
], "b", (t:UrlTree) => {
compareTrees(t, tree('a/b'));
});
});
@ -96,7 +96,7 @@ describe('applyRedirects', () => {
{path: 'b', component: ComponentB},
]},
{path: '', redirectTo: '/a/b'}
], "", t => {
], "", (t:UrlTree) => {
compareTrees(t, tree('a/b'));
});
});
@ -108,7 +108,7 @@ describe('applyRedirects', () => {
{path: '', redirectTo: 'b'}
]},
{path: '', redirectTo: 'a'}
], "", t => {
], "", (t:UrlTree) => {
compareTrees(t, tree('a/b'));
});
});
@ -120,7 +120,7 @@ describe('applyRedirects', () => {
{path: '', redirectTo: 'b'}
]},
{path: 'a', redirectTo: ''}
], "a", t => {
], "a", (t:UrlTree) => {
compareTrees(t, tree('b'));
});
});
@ -144,7 +144,7 @@ describe('applyRedirects', () => {
checkRedirect([
{path: '404', component: ComponentA},
{path: '**', redirectTo: '/404'},
], "/a/1(aux:c/d)", t => {
], "/a/1(aux:c/d)", (t:UrlTree) => {
compareTrees(t, tree('/404'));
});
});
@ -155,7 +155,7 @@ describe('applyRedirects', () => {
{path: 'b/:id', redirectTo: '/global/:id'}
]},
{path: '**', component: ComponentC}
], "/a/b/1", t => {
], "/a/b/1", (t:UrlTree) => {
compareTrees(t, tree('/global/1'));
});
});

View File

@ -56,7 +56,7 @@ function advanceNode(node: TreeNode<ActivatedRoute>): void {
}
function createState(config: RouterConfig, url: string): RouterStateSnapshot {
let res;
let res: RouterStateSnapshot;
recognize(RootComponent, config, tree(url), url).forEach(s => res = s);
return res;
}

View File

@ -1,7 +1,7 @@
import {DefaultUrlSerializer} from '../src/url_serializer';
import {UrlTree} from '../src/url_tree';
import {Params, PRIMARY_OUTLET} from '../src/shared';
import {ActivatedRouteSnapshot} from '../src/router_state';
import {ActivatedRouteSnapshot, RouterStateSnapshot} from '../src/router_state';
import {RouterConfig} from '../src/config';
import {recognize} from '../src/recognize';
@ -11,7 +11,7 @@ describe('recognize', () => {
{
path: 'a', component: ComponentA
}
], "a", s => {
], "a", (s:RouterStateSnapshot) => {
checkActivatedRoute(s.root, "", {}, RootComponent);
checkActivatedRoute(s.firstChild(s.root), "a", {}, ComponentA);
});
@ -22,7 +22,7 @@ describe('recognize', () => {
{ path: 'a', component: ComponentA },
{ path: 'b', component: ComponentB, outlet: 'left' },
{ path: 'c', component: ComponentC, outlet: 'right' }
], "a(left:b//right:c)", s => {
], "a(left:b//right:c)", (s:RouterStateSnapshot) => {
const c = s.children(s.root);
checkActivatedRoute(c[0], "a", {}, ComponentA);
checkActivatedRoute(c[1], "b", {}, ComponentB, 'left');
@ -58,7 +58,7 @@ describe('recognize', () => {
{ path: '/a/b', component: ComponentA, children: [
{path: 'c', component: ComponentC}
] },
], url, "a/b/c").subscribe(s => {
], url, "a/b/c").subscribe((s:RouterStateSnapshot) => {
expect(s.root._urlSegment).toBe(url.root);
expect(s.root._lastPathIndex).toBe(-1);
@ -76,7 +76,7 @@ describe('recognize', () => {
checkRecognize([
{path: 'a', component: ComponentA, children: [{path: ':id', component: ComponentB}]},
{path: 'a/:id', component: ComponentC}
], "a/paramA", s => {
], "a/paramA", (s:RouterStateSnapshot) => {
checkActivatedRoute(s.root, "", {}, RootComponent);
checkActivatedRoute(s.firstChild(s.root), "a", {}, ComponentA);
checkActivatedRoute(s.firstChild(<any>s.firstChild(s.root)), "paramA", {id: 'paramA'}, ComponentB);
@ -85,7 +85,7 @@ describe('recognize', () => {
checkRecognize([
{path: 'a', component: ComponentA},
{path: 'a/:id', component: ComponentC}
], "a/paramA", s => {
], "a/paramA", (s:RouterStateSnapshot) => {
checkActivatedRoute(s.root, "", {}, RootComponent);
checkActivatedRoute(s.firstChild(s.root), "a/paramA", {id: 'paramA'}, ComponentC);
});
@ -96,7 +96,7 @@ describe('recognize', () => {
{ path: 'a', component: ComponentA },
{ path: 'b', component: ComponentB, outlet: 'left' },
{ path: 'b', component: ComponentC, outlet: 'right' }
], "a(right:b)", s => {
], "a(right:b)", (s:RouterStateSnapshot) => {
const c = s.children(s.root);
checkActivatedRoute(c[0], "a", {}, ComponentA);
checkActivatedRoute(c[1], "b", {}, ComponentC, 'right');
@ -108,7 +108,7 @@ describe('recognize', () => {
{ path: 'a', component: ComponentA },
{ path: 'b', component: ComponentB, outlet: 'left' },
{ path: 'c', component: ComponentC, outlet: 'right' }
], "a(left:b(right:c))", s => {
], "a(left:b(right:c))", (s:RouterStateSnapshot) => {
const c = s.children(s.root);
checkActivatedRoute(c[0], "a", {}, ComponentA);
checkActivatedRoute(c[1], "b", {}, ComponentB, 'left');
@ -122,7 +122,7 @@ describe('recognize', () => {
{ path: 'b', component: ComponentB },
{ path: 'c', component: ComponentC, outlet: 'left' }
] },
], "a/(b//left:c)", s => {
], "a/(b//left:c)", (s:RouterStateSnapshot) => {
const c = s.children(<any>s.firstChild(s.root));
checkActivatedRoute(c[0], "b", {}, ComponentB, PRIMARY_OUTLET);
checkActivatedRoute(c[1], "c", {}, ComponentC, 'left');
@ -134,7 +134,7 @@ describe('recognize', () => {
{ path: 'a', component: ComponentA },
{ path: 'c', component: ComponentC, outlet: 'c' },
{ path: 'b', component: ComponentB, outlet: 'b' }
], "a(c:c//b:b)", s => {
], "a(c:c//b:b)", (s:RouterStateSnapshot) => {
const c = s.children(s.root);
checkActivatedRoute(c[0], "a", {}, ComponentA);
checkActivatedRoute(c[1], "b", {}, ComponentB, 'b');
@ -150,7 +150,7 @@ describe('recognize', () => {
]
},
{ path: 'c', component: ComponentC, outlet: 'left' }
], "a;a1=11;a2=22/b;b1=111;b2=222(left:c;c1=1111;c2=2222)", s => {
], "a;a1=11;a2=22/b;b1=111;b2=222(left:c;c1=1111;c2=2222)", (s:RouterStateSnapshot) => {
const c = s.children(s.root);
checkActivatedRoute(c[0], "a", {a1: '11', a2: '22'}, ComponentA);
checkActivatedRoute(s.firstChild(<any>c[0]), "b", {b1: '111', b2: '222'}, ComponentB);
@ -162,7 +162,7 @@ describe('recognize', () => {
it("should support root index routes", () => {
checkRecognize([
{index: true, component: ComponentA}
], "", s => {
], "", (s:RouterStateSnapshot) => {
checkActivatedRoute(s.firstChild(s.root), "", {}, ComponentA);
});
});
@ -170,7 +170,7 @@ describe('recognize', () => {
it("should support nested root index routes", () => {
checkRecognize([
{index: true, component: ComponentA, children: [{index: true, component: ComponentB}]}
], "", s => {
], "", (s:RouterStateSnapshot) => {
checkActivatedRoute(s.firstChild(s.root), "", {}, ComponentA);
checkActivatedRoute(s.firstChild(<any>s.firstChild(s.root)), "", {}, ComponentB);
});
@ -181,7 +181,7 @@ describe('recognize', () => {
{path: 'a', component: ComponentA, children: [
{index: true, component: ComponentB}
]}
], "a", s => {
], "a", (s:RouterStateSnapshot) => {
checkActivatedRoute(s.firstChild(s.root), "a", {}, ComponentA);
checkActivatedRoute(s.firstChild(<any>s.firstChild(s.root)), "", {}, ComponentB);
});
@ -197,7 +197,7 @@ describe('recognize', () => {
}
]
}
], "c/10", s => {
], "c/10", (s:RouterStateSnapshot) => {
checkActivatedRoute(s.firstChild(s.root), "", {}, ComponentA);
checkActivatedRoute(s.firstChild(<any>s.firstChild(s.root)), "", {}, ComponentB);
checkActivatedRoute(
@ -208,7 +208,7 @@ describe('recognize', () => {
xit("should pass parameters to every nested index route (case with non-index route)", () => {
checkRecognize([
{path: 'a', component: ComponentA, children: [{index: true, component: ComponentB}]}
], "/a;a=1", s => {
], "/a;a=1", (s:RouterStateSnapshot) => {
checkActivatedRoute(s.firstChild(s.root), "a", {a: '1'}, ComponentA);
checkActivatedRoute(s.firstChild(<any>s.firstChild(s.root)), "", {a: '1'}, ComponentB);
});
@ -219,7 +219,7 @@ describe('recognize', () => {
it("should support root index routes", () => {
recognize(RootComponent, [
{path: '', component: ComponentA}
], tree(""), "").forEach(s => {
], tree(""), "").forEach((s:RouterStateSnapshot) => {
checkActivatedRoute(s.firstChild(s.root), "", {}, ComponentA);
});
});
@ -227,7 +227,7 @@ describe('recognize', () => {
it("should support nested root index routes", () => {
recognize(RootComponent, [
{path: '', component: ComponentA, children: [{path: '', component: ComponentB}]}
], tree(""), "").forEach(s => {
], tree(""), "").forEach((s:RouterStateSnapshot) => {
checkActivatedRoute(s.firstChild(s.root), "", {}, ComponentA);
checkActivatedRoute(s.firstChild(<any>s.firstChild(s.root)), "", {}, ComponentB);
});
@ -237,7 +237,7 @@ describe('recognize', () => {
const url = tree("");
recognize(RootComponent, [
{path: '', component: ComponentA, children: [{path: '', component: ComponentB}]}
], url, "").forEach(s => {
], url, "").forEach((s:RouterStateSnapshot) => {
expect(s.root._urlSegment).toBe(url.root);
expect(s.root._lastPathIndex).toBe(-1);
@ -256,7 +256,7 @@ describe('recognize', () => {
{path: 'a', component: ComponentA, children: [
{path: '', component: ComponentB}
]}
], tree("a"), "a").forEach(s => {
], tree("a"), "a").forEach((s:RouterStateSnapshot) => {
checkActivatedRoute(s.firstChild(s.root), "a", {}, ComponentA);
checkActivatedRoute(s.firstChild(<any>s.firstChild(s.root)), "", {}, ComponentB);
});
@ -272,7 +272,7 @@ describe('recognize', () => {
}
]
}
], tree("c/10"), "c/10").forEach(s => {
], tree("c/10"), "c/10").forEach((s:RouterStateSnapshot) => {
checkActivatedRoute(s.firstChild(s.root), "", {}, ComponentA);
checkActivatedRoute(s.firstChild(<any>s.firstChild(s.root)), "", {}, ComponentB);
checkActivatedRoute(
@ -283,7 +283,7 @@ describe('recognize', () => {
xit("should pass parameters to every nested index route (case with non-index route)", () => {
recognize(RootComponent, [
{path: 'a', component: ComponentA, children: [{path: '', component: ComponentB}]}
], tree("/a;a=1"), "/a;a=1").forEach(s => {
], tree("/a;a=1"), "/a;a=1").forEach((s:RouterStateSnapshot) => {
checkActivatedRoute(s.firstChild(s.root), "a", {a: '1'}, ComponentA);
checkActivatedRoute(s.firstChild(<any>s.firstChild(s.root)), "", {a: '1'}, ComponentB);
});
@ -294,7 +294,7 @@ describe('recognize', () => {
it("should support simple wildcards", () => {
checkRecognize([
{path: '**', component: ComponentA}
], "a/b/c/d;a1=11", s => {
], "a/b/c/d;a1=11", (s:RouterStateSnapshot) => {
checkActivatedRoute(s.firstChild(s.root), "a/b/c/d", {a1:'11'}, ComponentA);
});
});
@ -303,7 +303,7 @@ describe('recognize', () => {
describe("query parameters", () => {
it("should support query params", () => {
const config = [{path: 'a', component: ComponentA}];
checkRecognize(config, "a?q=11", s => {
checkRecognize(config, "a?q=11", (s:RouterStateSnapshot) => {
expect(s.queryParams).toEqual({q: '11'});
});
});
@ -312,7 +312,7 @@ describe('recognize', () => {
describe("fragment", () => {
it("should support fragment", () => {
const config = [{path: 'a', component: ComponentA}];
checkRecognize(config, "a#f1", s => {
checkRecognize(config, "a#f1", (s:RouterStateSnapshot) => {
expect(s.fragment).toEqual("f1");
});
});
@ -324,7 +324,7 @@ describe('recognize', () => {
{ path: 'a', component: ComponentA },
{ path: 'b', component: ComponentB, outlet: 'aux' },
{ path: 'c', component: ComponentC, outlet: 'aux' }
], tree("a(aux:b//aux:c)"), "a(aux:b//aux:c)").subscribe((_) => {}, s => {
], tree("a(aux:b//aux:c)"), "a(aux:b//aux:c)").subscribe((_) => {}, (s:RouterStateSnapshot) => {
expect(s.toString()).toContain("Two segments cannot have the same outlet name: 'aux:b' and 'aux:c'.");
});
});
@ -332,7 +332,7 @@ describe('recognize', () => {
it("should error when no matching routes", () => {
recognize(RootComponent, [
{ path: 'a', component: ComponentA }
], tree("invalid"), "invalid").subscribe((_) => {}, s => {
], tree("invalid"), "invalid").subscribe((_) => {}, (s:RouterStateSnapshot) => {
expect(s.toString()).toContain("Cannot match any routes");
});
});
@ -340,7 +340,7 @@ describe('recognize', () => {
it("should error when no matching routes (too short)", () => {
recognize(RootComponent, [
{ path: 'a/:id', component: ComponentA }
], tree("a"), "a").subscribe((_) => {}, s => {
], tree("a"), "a").subscribe((_) => {}, (s:RouterStateSnapshot) => {
expect(s.toString()).toContain("Cannot match any routes");
});
});

View File

@ -16,6 +16,7 @@ import {
import {TestComponentBuilder, ComponentFixture} from '@angular/compiler/testing';
import { ComponentResolver } from '@angular/core';
import { Location } from '@angular/common';
import { SpyLocation } from '@angular/common/testing';
import { UrlSerializer, DefaultUrlSerializer, RouterOutletMap, Router, ActivatedRoute, ROUTER_DIRECTIVES, Params,
RouterStateSnapshot, ActivatedRouteSnapshot, CanActivate, CanDeactivate, Event, NavigationStart, NavigationEnd, NavigationCancel, NavigationError, RoutesRecognized, RouterConfig } from '../src/index';
@ -37,19 +38,19 @@ describe("Integration", () => {
{provide: Location, useClass: SpyLocation},
{
provide: Router,
useFactory: (resolver, urlSerializer, outletMap, location, injector) => {
useFactory: (resolver:ComponentResolver, urlSerializer:UrlSerializer, outletMap:RouterOutletMap, location:Location, injector:Injector) => {
const r = new Router(RootCmp, resolver, urlSerializer, outletMap, location, injector, config);
r.initialNavigation();
return r;
},
deps: [ComponentResolver, UrlSerializer, RouterOutletMap, Location, Injector]
},
{provide: ActivatedRoute, useFactory: (r) => r.routerState.root, deps: [Router]},
{provide: ActivatedRoute, useFactory: (r:Router) => r.routerState.root, deps: [Router]},
];
});
it('should navigate with a provided config',
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -61,7 +62,7 @@ describe("Integration", () => {
it('should update location when navigating',
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -80,7 +81,7 @@ describe("Integration", () => {
})));
it('should navigate back and forward',
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -109,7 +110,7 @@ describe("Integration", () => {
})));
it('should navigate when locations changes',
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -122,14 +123,14 @@ describe("Integration", () => {
router.navigateByUrl('/team/22/user/victor');
advance(fixture);
location.simulateHashChange("/team/22/user/fedor");
(<any>location).simulateHashChange("/team/22/user/fedor");
advance(fixture);
expect(fixture.debugElement.nativeElement).toHaveText('team 22 { user fedor, right: }');
})));
it('should update the location when the matched route does not change',
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -149,7 +150,7 @@ describe("Integration", () => {
})));
it('should support secondary routes',
fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => {
fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -168,7 +169,7 @@ describe("Integration", () => {
})));
it('should deactivate outlets',
fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => {
fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -189,7 +190,7 @@ describe("Integration", () => {
})));
it('should deactivate nested outlets',
fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => {
fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -211,7 +212,7 @@ describe("Integration", () => {
})));
it('should set query params and fragment',
fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => {
fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -229,7 +230,7 @@ describe("Integration", () => {
})));
it('should push params only when they change',
fakeAsync(inject([Router, TestComponentBuilder], (router, tcb:TestComponentBuilder) => {
fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -255,7 +256,7 @@ describe("Integration", () => {
})));
it('should work when navigating to /',
fakeAsync(inject([Router, TestComponentBuilder], (router, tcb:TestComponentBuilder) => {
fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -276,7 +277,7 @@ describe("Integration", () => {
})));
it("should cancel in-flight navigations",
fakeAsync(inject([Router, TestComponentBuilder], (router, tcb:TestComponentBuilder) => {
fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -284,7 +285,7 @@ describe("Integration", () => {
{ path: '/user/:name', component: UserCmp }
]);
const recordedEvents = [];
const recordedEvents:any = [];
router.events.forEach(e => recordedEvents.push(e));
router.navigateByUrl('/user/init');
@ -292,7 +293,7 @@ describe("Integration", () => {
const user = fixture.debugElement.children[1].componentInstance;
let r1, r2;
let r1:any, r2:any;
router.navigateByUrl('/user/victor').then(_ => r1 = _);
router.navigateByUrl('/user/fedor').then(_ => r2 = _);
advance(fixture);
@ -318,7 +319,7 @@ describe("Integration", () => {
})));
it("should handle failed navigations gracefully",
fakeAsync(inject([Router, TestComponentBuilder], (router, tcb:TestComponentBuilder) => {
fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -326,10 +327,10 @@ describe("Integration", () => {
{ path: '/user/:name', component: UserCmp }
]);
const recordedEvents = [];
const recordedEvents:any = [];
router.events.forEach(e => recordedEvents.push(e));
let e;
let e:any;
router.navigateByUrl('/invalid').catch(_ => e = _);
advance(fixture);
expect(e.message).toContain("Cannot match any routes");
@ -350,7 +351,7 @@ describe("Integration", () => {
})));
it('should replace state when path is equal to current path',
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -377,7 +378,7 @@ describe("Integration", () => {
describe("router links", () => {
it("should support string router links",
fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => {
fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -401,7 +402,7 @@ describe("Integration", () => {
})));
it("should support absolute router links",
fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => {
fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -425,7 +426,7 @@ describe("Integration", () => {
})));
it("should support relative router links",
fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => {
fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -451,7 +452,7 @@ describe("Integration", () => {
})));
it("should support top-level link",
fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => {
fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => {
let fixture = tcb.createFakeAsync(AbsoluteLinkCmp);
advance(fixture);
@ -459,7 +460,7 @@ describe("Integration", () => {
})));
it("should support query params and fragments",
fakeAsync(inject([Router, Location, TestComponentBuilder], (router, location, tcb) => {
fakeAsync(inject([Router, Location, TestComponentBuilder], (router:Router, location:Location, tcb:TestComponentBuilder) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -486,7 +487,7 @@ describe("Integration", () => {
});
describe("redirects", () => {
it("should work", fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
it("should work", fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -506,11 +507,11 @@ describe("Integration", () => {
describe("CanActivate", () => {
describe("should not activate a route when CanActivate returns false", () => {
beforeEachProviders(() => [
{provide: 'alwaysFalse', useValue: (a, b) => false}
{provide: 'alwaysFalse', useValue: (a:any, b:any) => false}
]);
it('works',
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -531,7 +532,7 @@ describe("Integration", () => {
]);
it('works',
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -556,7 +557,7 @@ describe("Integration", () => {
beforeEachProviders(() => [AlwaysTrue]);
it('works',
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -579,7 +580,7 @@ describe("Integration", () => {
]);
it('works',
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -607,7 +608,7 @@ describe("Integration", () => {
it('works',
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -632,7 +633,7 @@ describe("Integration", () => {
})));
it('works with a nested route',
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -671,7 +672,7 @@ describe("Integration", () => {
beforeEachProviders(() => [AlwaysTrue]);
it('works',
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -698,7 +699,7 @@ describe("Integration", () => {
]);
it('works',
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -719,7 +720,7 @@ describe("Integration", () => {
describe("routerActiveLink", () => {
it("should set the class when the link is active (exact = true)",
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -746,7 +747,7 @@ describe("Integration", () => {
})));
it("should set the class on a parent element when the link is active (exact = true)",
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);
@ -773,7 +774,7 @@ describe("Integration", () => {
})));
it("should set the class when the link is active (exact = false)",
fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => {
fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => {
const fixture = tcb.createFakeAsync(RootCmp);
advance(fixture);