refactor(router): rename navigate and navigateInstruction methods
This commit is contained in:
@@ -159,7 +159,7 @@ export class Router {
|
||||
* If the given URL begins with a `/`, router will navigate absolutely.
|
||||
* If the given URL does not begin with `/`, the router will navigate relative to this component.
|
||||
*/
|
||||
navigate(url: string, _skipLocationChange: boolean = false): Promise<any> {
|
||||
navigateByUrl(url: string, _skipLocationChange: boolean = false): Promise<any> {
|
||||
return this._currentNavigation = this._currentNavigation.then((_) => {
|
||||
this.lastNavigationAttempt = url;
|
||||
this._startNavigating();
|
||||
@@ -177,8 +177,8 @@ export class Router {
|
||||
* Navigate via the provided instruction. Returns a promise that resolves when navigation is
|
||||
* complete.
|
||||
*/
|
||||
navigateInstruction(instruction: Instruction,
|
||||
_skipLocationChange: boolean = false): Promise<any> {
|
||||
navigateByInstruction(instruction: Instruction,
|
||||
_skipLocationChange: boolean = false): Promise<any> {
|
||||
if (isBlank(instruction)) {
|
||||
return _resolveToFalse;
|
||||
}
|
||||
@@ -373,7 +373,7 @@ export class Router {
|
||||
if (isBlank(this.lastNavigationAttempt)) {
|
||||
return this._currentNavigation;
|
||||
}
|
||||
return this.navigate(this.lastNavigationAttempt);
|
||||
return this.navigateByUrl(this.lastNavigationAttempt);
|
||||
}
|
||||
|
||||
|
||||
@@ -445,10 +445,11 @@ export class RootRouter extends Router {
|
||||
hostComponent: Type) {
|
||||
super(registry, pipeline, null, hostComponent);
|
||||
this._location = location;
|
||||
this._location.subscribe((change) => this.navigate(change['url'], isPresent(change['pop'])));
|
||||
this._location.subscribe((change) =>
|
||||
this.navigateByUrl(change['url'], isPresent(change['pop'])));
|
||||
|
||||
this.registry.configFromComponent(hostComponent);
|
||||
this.navigate(location.path());
|
||||
this.navigateByUrl(location.path());
|
||||
}
|
||||
|
||||
commit(instruction: Instruction, _skipLocationChange: boolean = false): Promise<any> {
|
||||
@@ -471,15 +472,15 @@ class ChildRouter extends Router {
|
||||
}
|
||||
|
||||
|
||||
navigate(url: string, _skipLocationChange: boolean = false): Promise<any> {
|
||||
navigateByUrl(url: string, _skipLocationChange: boolean = false): Promise<any> {
|
||||
// Delegate navigation to the root router
|
||||
return this.parent.navigate(url, _skipLocationChange);
|
||||
return this.parent.navigateByUrl(url, _skipLocationChange);
|
||||
}
|
||||
|
||||
navigateInstruction(instruction: Instruction,
|
||||
_skipLocationChange: boolean = false): Promise<any> {
|
||||
navigateByInstruction(instruction: Instruction,
|
||||
_skipLocationChange: boolean = false): Promise<any> {
|
||||
// Delegate navigation to the root router
|
||||
return this.parent.navigateInstruction(instruction, _skipLocationChange);
|
||||
return this.parent.navigateByInstruction(instruction, _skipLocationChange);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ export class RouterLink {
|
||||
}
|
||||
|
||||
onClick(): boolean {
|
||||
this._router.navigateInstruction(this._navigationInstruction);
|
||||
this._router.navigateByInstruction(this._navigationInstruction);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ export function main() {
|
||||
it('should call the onActivate hook', inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigate('/on-activate'))
|
||||
.then((_) => rtr.navigateByUrl('/on-activate'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('activate cmp');
|
||||
@@ -110,7 +110,7 @@ export function main() {
|
||||
completer.resolve(true);
|
||||
}
|
||||
});
|
||||
rtr.navigate('/parent-activate/child-activate')
|
||||
rtr.navigateByUrl('/parent-activate/child-activate')
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('parent {activate cmp}');
|
||||
@@ -126,8 +126,8 @@ export function main() {
|
||||
it('should call the onDeactivate hook', inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigate('/on-deactivate'))
|
||||
.then((_) => rtr.navigate('/a'))
|
||||
.then((_) => rtr.navigateByUrl('/on-deactivate'))
|
||||
.then((_) => rtr.navigateByUrl('/a'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('A');
|
||||
@@ -140,7 +140,7 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigate('/parent-deactivate/child-deactivate'))
|
||||
.then((_) => rtr.navigateByUrl('/parent-deactivate/child-deactivate'))
|
||||
.then((_) => {
|
||||
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
|
||||
if (ev.startsWith('deactivate')) {
|
||||
@@ -149,7 +149,7 @@ export function main() {
|
||||
expect(rootTC.nativeElement).toHaveText('parent {deactivate cmp}');
|
||||
}
|
||||
});
|
||||
rtr.navigate('/a').then((_) => {
|
||||
rtr.navigateByUrl('/a').then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('A');
|
||||
expect(log).toEqual([
|
||||
@@ -165,14 +165,14 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigate('/on-reuse/1/a'))
|
||||
.then((_) => rtr.navigateByUrl('/on-reuse/1/a'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(log).toEqual([]);
|
||||
expect(rootTC.nativeElement).toHaveText('reuse {A}');
|
||||
expect(cmpInstanceCount).toBe(1);
|
||||
})
|
||||
.then((_) => rtr.navigate('/on-reuse/2/b'))
|
||||
.then((_) => rtr.navigateByUrl('/on-reuse/2/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(log).toEqual(['reuse: /on-reuse/1 -> /on-reuse/2']);
|
||||
@@ -187,14 +187,14 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigate('/never-reuse/1/a'))
|
||||
.then((_) => rtr.navigateByUrl('/never-reuse/1/a'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(log).toEqual([]);
|
||||
expect(rootTC.nativeElement).toHaveText('reuse {A}');
|
||||
expect(cmpInstanceCount).toBe(1);
|
||||
})
|
||||
.then((_) => rtr.navigate('/never-reuse/2/b'))
|
||||
.then((_) => rtr.navigateByUrl('/never-reuse/2/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(log).toEqual([]);
|
||||
@@ -214,7 +214,7 @@ export function main() {
|
||||
completer.resolve(true);
|
||||
}
|
||||
});
|
||||
rtr.navigate('/can-activate/a')
|
||||
rtr.navigateByUrl('/can-activate/a')
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('canActivate {A}');
|
||||
@@ -234,7 +234,7 @@ export function main() {
|
||||
completer.resolve(false);
|
||||
}
|
||||
});
|
||||
rtr.navigate('/can-activate/a')
|
||||
rtr.navigateByUrl('/can-activate/a')
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('');
|
||||
@@ -248,7 +248,7 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigate('/can-deactivate/a'))
|
||||
.then((_) => rtr.navigateByUrl('/can-deactivate/a'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('canDeactivate {A}');
|
||||
@@ -260,7 +260,7 @@ export function main() {
|
||||
}
|
||||
});
|
||||
|
||||
rtr.navigate('/a').then((_) => {
|
||||
rtr.navigateByUrl('/a').then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('A');
|
||||
expect(log).toEqual(['canDeactivate: /can-deactivate -> /a']);
|
||||
@@ -273,7 +273,7 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigate('/can-deactivate/a'))
|
||||
.then((_) => rtr.navigateByUrl('/can-deactivate/a'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('canDeactivate {A}');
|
||||
@@ -285,7 +285,7 @@ export function main() {
|
||||
}
|
||||
});
|
||||
|
||||
rtr.navigate('/a').then((_) => {
|
||||
rtr.navigateByUrl('/a').then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('canDeactivate {A}');
|
||||
expect(log).toEqual(['canDeactivate: /can-deactivate -> /a']);
|
||||
@@ -299,7 +299,7 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigate('/activation-hooks/child'))
|
||||
.then((_) => rtr.navigateByUrl('/activation-hooks/child'))
|
||||
.then((_) => {
|
||||
expect(log).toEqual([
|
||||
'canActivate child: null -> /child',
|
||||
@@ -309,7 +309,7 @@ export function main() {
|
||||
]);
|
||||
|
||||
log = [];
|
||||
return rtr.navigate('/a');
|
||||
return rtr.navigateByUrl('/a');
|
||||
})
|
||||
.then((_) => {
|
||||
expect(log).toEqual([
|
||||
@@ -325,7 +325,7 @@ export function main() {
|
||||
it('should only run reuse hooks when reusing', inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigate('/reuse-hooks/1'))
|
||||
.then((_) => rtr.navigateByUrl('/reuse-hooks/1'))
|
||||
.then((_) => {
|
||||
expect(log).toEqual(
|
||||
['canActivate: null -> /reuse-hooks/1', 'onActivate: null -> /reuse-hooks/1']);
|
||||
@@ -338,7 +338,7 @@ export function main() {
|
||||
|
||||
|
||||
log = [];
|
||||
return rtr.navigate('/reuse-hooks/2');
|
||||
return rtr.navigateByUrl('/reuse-hooks/2');
|
||||
})
|
||||
.then((_) => {
|
||||
expect(log).toEqual([
|
||||
@@ -352,7 +352,7 @@ export function main() {
|
||||
it('should not run reuse hooks when not reusing', inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigate('/reuse-hooks/1'))
|
||||
.then((_) => rtr.navigateByUrl('/reuse-hooks/1'))
|
||||
.then((_) => {
|
||||
expect(log).toEqual(
|
||||
['canActivate: null -> /reuse-hooks/1', 'onActivate: null -> /reuse-hooks/1']);
|
||||
@@ -364,7 +364,7 @@ export function main() {
|
||||
});
|
||||
|
||||
log = [];
|
||||
return rtr.navigate('/reuse-hooks/2');
|
||||
return rtr.navigateByUrl('/reuse-hooks/2');
|
||||
})
|
||||
.then((_) => {
|
||||
expect(log).toEqual([
|
||||
|
||||
@@ -75,7 +75,7 @@ export function main() {
|
||||
it('should work in a simple case', inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})]))
|
||||
.then((_) => rtr.navigate('/test'))
|
||||
.then((_) => rtr.navigateByUrl('/test'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('hello');
|
||||
@@ -88,12 +88,12 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => rtr.config([new Route({path: '/user/:name', component: UserCmp})]))
|
||||
.then((_) => rtr.navigate('/user/brian'))
|
||||
.then((_) => rtr.navigateByUrl('/user/brian'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('hello brian');
|
||||
})
|
||||
.then((_) => rtr.navigate('/user/igor'))
|
||||
.then((_) => rtr.navigateByUrl('/user/igor'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('hello igor');
|
||||
@@ -105,7 +105,7 @@ export function main() {
|
||||
it('should navigate to child routes', inject([AsyncTestCompleter], (async) => {
|
||||
compile('outer { <router-outlet></router-outlet> }')
|
||||
.then((_) => rtr.config([new Route({path: '/a/...', component: ParentCmp})]))
|
||||
.then((_) => rtr.navigate('/a/b'))
|
||||
.then((_) => rtr.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('outer { inner { hello } }');
|
||||
@@ -117,7 +117,7 @@ export function main() {
|
||||
it('should navigate to child routes of async routes', inject([AsyncTestCompleter], (async) => {
|
||||
compile('outer { <router-outlet></router-outlet> }')
|
||||
.then((_) => rtr.config([new AsyncRoute({path: '/a/...', loader: parentLoader})]))
|
||||
.then((_) => rtr.navigate('/a/b'))
|
||||
.then((_) => rtr.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('outer { inner { hello } }');
|
||||
@@ -133,7 +133,7 @@ export function main() {
|
||||
new Redirect({path: '/original', redirectTo: '/redirected'}),
|
||||
new Route({path: '/redirected', component: HelloCmp})
|
||||
]))
|
||||
.then((_) => rtr.navigate('/original'))
|
||||
.then((_) => rtr.navigateByUrl('/original'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('hello');
|
||||
@@ -146,13 +146,13 @@ export function main() {
|
||||
it('should reuse common parent components', inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => rtr.config([new Route({path: '/team/:id/...', component: TeamCmp})]))
|
||||
.then((_) => rtr.navigate('/team/angular/user/rado'))
|
||||
.then((_) => rtr.navigateByUrl('/team/angular/user/rado'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(cmpInstanceCount).toBe(1);
|
||||
expect(rootTC.nativeElement).toHaveText('team angular { hello rado }');
|
||||
})
|
||||
.then((_) => rtr.navigate('/team/angular/user/victor'))
|
||||
.then((_) => rtr.navigateByUrl('/team/angular/user/victor'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(cmpInstanceCount).toBe(1);
|
||||
@@ -165,14 +165,14 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => rtr.config([new Route({path: '/team/:id/...', component: TeamCmp})]))
|
||||
.then((_) => rtr.navigate('/team/angular/user/rado'))
|
||||
.then((_) => rtr.navigateByUrl('/team/angular/user/rado'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(cmpInstanceCount).toBe(1);
|
||||
expect(childCmpInstanceCount).toBe(1);
|
||||
expect(rootTC.nativeElement).toHaveText('team angular { hello rado }');
|
||||
})
|
||||
.then((_) => rtr.navigate('/team/dart/user/rado'))
|
||||
.then((_) => rtr.navigateByUrl('/team/dart/user/rado'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(cmpInstanceCount).toBe(2);
|
||||
@@ -187,7 +187,7 @@ export function main() {
|
||||
.then((_) => rtr.config([
|
||||
new Route({path: '/route-data', component: RouteDataCmp, data: {'isAdmin': true}})
|
||||
]))
|
||||
.then((_) => rtr.navigate('/route-data'))
|
||||
.then((_) => rtr.navigateByUrl('/route-data'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText(Json.stringify({'isAdmin': true}));
|
||||
@@ -202,7 +202,7 @@ export function main() {
|
||||
new AsyncRoute(
|
||||
{path: '/route-data', loader: AsyncRouteDataCmp, data: {isAdmin: true}})
|
||||
]))
|
||||
.then((_) => rtr.navigate('/route-data'))
|
||||
.then((_) => rtr.navigateByUrl('/route-data'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText(Json.stringify({'isAdmin': true}));
|
||||
@@ -215,7 +215,7 @@ export function main() {
|
||||
compile()
|
||||
.then((_) => rtr.config(
|
||||
[new Route({path: '/route-data-default', component: RouteDataCmp})]))
|
||||
.then((_) => rtr.navigate('/route-data-default'))
|
||||
.then((_) => rtr.navigateByUrl('/route-data-default'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('null');
|
||||
@@ -228,7 +228,7 @@ export function main() {
|
||||
.then((_) => rtr.config([
|
||||
new Route({path: '/route-data-array', component: RouteDataCmp, data: [1, 2, 3]})
|
||||
]))
|
||||
.then((_) => rtr.navigate('/route-data-array'))
|
||||
.then((_) => rtr.navigateByUrl('/route-data-array'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText(Json.stringify([1, 2, 3]));
|
||||
@@ -242,7 +242,7 @@ export function main() {
|
||||
new Route(
|
||||
{path: '/route-data-string', component: RouteDataCmp, data: 'hello world'})
|
||||
]))
|
||||
.then((_) => rtr.navigate('/route-data-string'))
|
||||
.then((_) => rtr.navigateByUrl('/route-data-string'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText(Json.stringify('hello world'));
|
||||
@@ -254,7 +254,7 @@ export function main() {
|
||||
it('should recognize a simple case', inject([AsyncTestCompleter], (async) => {
|
||||
compile()
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: AuxCmp})]))
|
||||
.then((_) => rtr.navigate('/hello(modal)'))
|
||||
.then((_) => rtr.navigateByUrl('/hello(modal)'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('main {hello} | aux {modal}');
|
||||
|
||||
@@ -72,7 +72,7 @@ export function main() {
|
||||
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
|
||||
tcb.createAsync(AppCmp).then((rootTC) => {
|
||||
var router = rootTC.componentInstance.router;
|
||||
PromiseWrapper.catchError(router.navigate('/cause-error'), (error) => {
|
||||
PromiseWrapper.catchError(router.navigateByUrl('/cause-error'), (error) => {
|
||||
expect(rootTC.nativeElement).toHaveText('outer { oh no }');
|
||||
expect(error).toContainError('oops!');
|
||||
async.done();
|
||||
@@ -123,11 +123,11 @@ export function main() {
|
||||
if (flipped) {
|
||||
location.back();
|
||||
} else {
|
||||
router.navigate(nextUrl);
|
||||
router.navigateByUrl(nextUrl);
|
||||
}
|
||||
});
|
||||
|
||||
router.navigate(history[0][0]);
|
||||
router.navigateByUrl(history[0][0]);
|
||||
});
|
||||
}), 1000);
|
||||
});
|
||||
@@ -146,7 +146,7 @@ export function main() {
|
||||
expect(rootTC.componentInstance.location.path()).toEqual('/parent/child');
|
||||
async.done();
|
||||
});
|
||||
router.navigate('/parent/child');
|
||||
router.navigateByUrl('/parent/child');
|
||||
});
|
||||
}), 1000);
|
||||
|
||||
@@ -165,7 +165,7 @@ export function main() {
|
||||
.toEqual('/my/app/parent/child');
|
||||
async.done();
|
||||
});
|
||||
router.navigate('/parent/child');
|
||||
router.navigateByUrl('/parent/child');
|
||||
});
|
||||
}),
|
||||
1000);
|
||||
@@ -190,7 +190,7 @@ export function main() {
|
||||
.toEqual('/qs?q=search-for-something');*/
|
||||
async.done();
|
||||
});
|
||||
router.navigate('/qs?q=search-for-something');
|
||||
router.navigateByUrl('/qs?q=search-for-something');
|
||||
rootTC.detectChanges();
|
||||
});
|
||||
}), 1000);
|
||||
|
||||
@@ -76,7 +76,7 @@ export function main() {
|
||||
compile('<a href="hello" [router-link]="[\'./user\']"></a>')
|
||||
.then((_) =>
|
||||
router.config([new Route({path: '/user', component: UserCmp, as: 'user'})]))
|
||||
.then((_) => router.navigate('/a/b'))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(getHref(rootTC)).toEqual('/my/base/user');
|
||||
@@ -89,7 +89,7 @@ export function main() {
|
||||
compile('<a href="hello" [router-link]="[\'./user\']"></a>')
|
||||
.then((_) =>
|
||||
router.config([new Route({path: '/user', component: UserCmp, as: 'user'})]))
|
||||
.then((_) => router.navigate('/a/b'))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(getHref(rootTC)).toEqual('/user');
|
||||
@@ -102,7 +102,7 @@ export function main() {
|
||||
compile('<a href="hello" [router-link]="[\'./user\', {name: name}]">{{name}}</a>')
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/user/:name', component: UserCmp, as: 'user'})]))
|
||||
.then((_) => router.navigate('/a/b'))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.componentInstance.name = 'brian';
|
||||
rootTC.detectChanges();
|
||||
@@ -118,7 +118,7 @@ export function main() {
|
||||
compile()
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/page/:number', component: SiblingPageCmp, as: 'page'})]))
|
||||
.then((_) => router.navigate('/page/1'))
|
||||
.then((_) => router.navigateByUrl('/page/1'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(DOM.getAttribute(
|
||||
@@ -159,7 +159,7 @@ export function main() {
|
||||
compile()
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/book/:title/...', component: BookCmp, as: 'book'})]))
|
||||
.then((_) => router.navigate('/book/1984/page/1'))
|
||||
.then((_) => router.navigateByUrl('/book/1984/page/1'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(DOM.getAttribute(
|
||||
@@ -206,7 +206,7 @@ export function main() {
|
||||
|
||||
async.done();
|
||||
});
|
||||
router.navigate('/better-child');
|
||||
router.navigateByUrl('/better-child');
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -247,7 +247,7 @@ export function main() {
|
||||
|
||||
async.done();
|
||||
});
|
||||
router.navigate('/child-with-grandchild/grandchild');
|
||||
router.navigateByUrl('/child-with-grandchild/grandchild');
|
||||
});
|
||||
}));
|
||||
});
|
||||
@@ -265,7 +265,7 @@ export function main() {
|
||||
compile('<a href="hello" [router-link]="[\'./user\']"></a>')
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/user', component: UserCmp, as: 'user'})]))
|
||||
.then((_) => router.navigate('/a/b'))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
|
||||
@@ -286,7 +286,7 @@ export function main() {
|
||||
compile('<a href="hello" [router-link]="[\'./user\']"></a>')
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/user', component: UserCmp, as: 'user'})]))
|
||||
.then((_) => router.navigate('/a/b'))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ export function main() {
|
||||
expect(applicationRef.hostComponent.location.path()).toEqual('/parent/child');
|
||||
async.done();
|
||||
});
|
||||
router.navigate('/parent/child');
|
||||
router.navigateByUrl('/parent/child');
|
||||
});
|
||||
}), 1000);
|
||||
|
||||
@@ -78,7 +78,7 @@ export function main() {
|
||||
expect(applicationRef.hostComponent.location.path()).toEqual('/after');
|
||||
async.done();
|
||||
});
|
||||
router.navigate('/before');
|
||||
router.navigateByUrl('/before');
|
||||
});
|
||||
}), 1000);
|
||||
|
||||
@@ -92,7 +92,7 @@ export function main() {
|
||||
expect(applicationRef.hostComponent.location.path()).toEqual('/hello');
|
||||
async.done();
|
||||
});
|
||||
router.navigate('/hello');
|
||||
router.navigateByUrl('/hello');
|
||||
});
|
||||
}), 1000);
|
||||
|
||||
@@ -107,7 +107,7 @@ export function main() {
|
||||
expect(applicationRef.hostComponent.location.path()).toEqual('/hello');
|
||||
async.done();
|
||||
});
|
||||
router.navigate('/hello');
|
||||
router.navigateByUrl('/hello');
|
||||
});
|
||||
}), 1000);
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ export function main() {
|
||||
testComponent.detectChanges();
|
||||
// TODO: shouldn't this be just 'click' rather than '^click'?
|
||||
testComponent.query(By.css('a')).triggerEventHandler('click', null);
|
||||
expect(router.spy('navigateInstruction')).toHaveBeenCalledWith(dummyInstruction);
|
||||
expect(router.spy('navigateByInstruction')).toHaveBeenCalledWith(dummyInstruction);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -68,7 +68,7 @@ export function main() {
|
||||
|
||||
router.registerPrimaryOutlet(outlet)
|
||||
.then((_) => router.config([new Route({path: '/a', component: DummyComponent})]))
|
||||
.then((_) => router.navigate('/a'))
|
||||
.then((_) => router.navigateByUrl('/a'))
|
||||
.then((_) => {
|
||||
expect(outlet.spy('activate')).toHaveBeenCalled();
|
||||
expect(location.urlChanges).toEqual(['/a']);
|
||||
@@ -82,7 +82,7 @@ export function main() {
|
||||
|
||||
router.registerPrimaryOutlet(outlet)
|
||||
.then((_) => router.config([new Route({path: '/b', component: DummyComponent})]))
|
||||
.then((_) => router.navigate('/b', true))
|
||||
.then((_) => router.navigateByUrl('/b', true))
|
||||
.then((_) => {
|
||||
expect(outlet.spy('activate')).toHaveBeenCalled();
|
||||
expect(location.urlChanges).toEqual([]);
|
||||
@@ -95,7 +95,7 @@ export function main() {
|
||||
var outlet = makeDummyOutlet();
|
||||
|
||||
router.registerPrimaryOutlet(outlet)
|
||||
.then((_) => router.navigate('/a'))
|
||||
.then((_) => router.navigateByUrl('/a'))
|
||||
.then((_) => {
|
||||
expect(outlet.spy('activate')).not.toHaveBeenCalled();
|
||||
return router.config([new Route({path: '/a', component: DummyComponent})]);
|
||||
@@ -146,7 +146,7 @@ export function main() {
|
||||
router.config([new AsyncRoute({path: '/first', loader: loader, as: 'FirstCmp'})]);
|
||||
|
||||
var instruction = router.generate(['/FirstCmp']);
|
||||
router.navigateInstruction(instruction)
|
||||
router.navigateByInstruction(instruction)
|
||||
.then((_) => {
|
||||
expect(outlet.spy('activate')).toHaveBeenCalled();
|
||||
async.done();
|
||||
@@ -162,7 +162,7 @@ export function main() {
|
||||
new Route({path: '/a', component: DummyComponent, as: 'A'}),
|
||||
new Route({path: '/b', component: DummyComponent, as: 'B'})
|
||||
]))
|
||||
.then((_) => router.navigate('/a'))
|
||||
.then((_) => router.navigateByUrl('/a'))
|
||||
.then((_) => {
|
||||
var instruction = router.generate(['/A']);
|
||||
var otherInstruction = router.generate(['/B']);
|
||||
|
||||
Reference in New Issue
Block a user