How to test Angular2's router.navigate?

前端 未结 4 1044
囚心锁ツ
囚心锁ツ 2021-01-31 07:58

I\'ve run into missing messages in other unit tests, but just to have a nice isolated example, I created an AuthGuard that checks if a user is

4条回答
  •  甜味超标
    2021-01-31 09:03

    this worked for me

    describe('navigateExample', () => {
        it('navigate Example', () => {
            const routerstub: Router = TestBed.get(Router);
            spyOn(routerstub, 'navigate');
            component.navigateExample();
        });
    });
    

提交回复
热议问题