使用Jasmine then()在Jasmine中进行角度测试的路由器

时间:2019-03-11 08:22:39

标签: angular jasmine karma-runner

在.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()?

0 个答案:

没有答案