0
route.navigate
をテストするにはどうすればよいですか?router.routerState is undefined角度2.1テスト
it('Should log in and navigate to dashboard', fakeAsync(inject([LoginService, Router, Location], (authService: LoginService, router: Router, location: Location) => {
let button = fixture.debugElement.nativeElement.querySelector('#login');
spyOn(authService, 'login').and.returnValue(Observable.of(true));
button.click();
tick(1000);
expect(component.loading).toBe(false);
})));
私はあなたがそう、router.activate
はモックルータを注入されると呼ばなっているかどうかをテストするために何をすべきかangular 2.1
ルート有効かどうかを確認する方法を示していないことの例... –
あなたはそこから彼の例との仕事を取るだろう...ルータがどのように注入されるのかを見てください(https://gist.github.com/joeeames/0ddcfe8f0576bc7651ae99e6b59e81ea#file-routing-test-L42)?そのルータの 'activate'メソッドを覗き込むことができます。アプリケーションが使用しているルータなので...意味がありますか? – gonzofish