在为路由编写角度单元测试时,是否可以使用真实值进行导航,或者我们应该使用 fakeAsync 进行路由器导航?
选项1
it('navigate to "home" takes you to /home', fakeAsync(() => {
router.navigate(['home']);
tick();
expect(location.path()).toBe('/home');
}));
选项 2
it('navigate to "home" takes you to /home', () => {
router.navigate(['home']).then(() => {
expect(location.path()).toBe('/home');
});
});