How do I unit test routers in Angular version 2.0.0 with karma and jasmine?
Here\'s what my old unit test looks like in version 2.0.0-beta.14
Instead of using useValue for routerStub, you can use useClass in the providers and it really worked for me.
export class RouterStub {
public url: string = '/';
constructor() { }
enter code here
navigateByUrl(url: any) {
this.url = url;
}
}
And in the beforeEach just instantiate the routerStub object like
routerStub = new RouterStub()
And in the test cases
component.router.navigateByUrl('/test');
fixture.detectChanges();