0
如何测试route.navigate
?我需要检查,如果点击按钮后改变路线。这里是我的测试:router.routerState未定义Angular 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);
})));
我使用angular 2.1
这个例子没有显示如何检查航线活跃... –
你会采取从那里他为榜样,工作...看看[路由器如何注入](https://gist.github.com/joeeames/0ddcfe8f0576bc7651ae99e6b59e81ea#file-routing-test-L42)?那么你可以窥探该路由器的'activate'方法,因为它是应用程序正在使用的路由器......有意义吗? – gonzofish