在.ts中,我有:
this.router.navigateByUrl('/', {skipLocationChange: true}).then(() => this.router.navigate([LangParams.activeLang, 'login'], {queryParams: {returnUrl: returnUrl}}));
并测试
it('should navigate to /login', inject([AuthStore, AuthenticationService, Router],
(authStore: AuthStore, authService: AuthenticationService, router: Router) => {
spyOn(authService, 'logout');
const routerSpy = spyOn(router, 'navigateByUrl').and.returnValue(Promise.resolve(true));
authStore.logout();
expect(routerSpy).toHaveBeenCalledWith('/', {skipLocationChange: true});
}));
我如何在then()中测试navigation()?