@@ -3,6 +3,9 @@ import { AuthGuard } from './auth.guard';
33describe ( 'AuthGuard' , ( ) => {
44 let mockRouter : any ;
55 let mockUserService : any ;
6+
7+ afterEach ( ( ) => { vi . restoreAllMocks ( ) ; } ) ;
8+
69 beforeEach ( ( ) => {
710 mockRouter = {
811 navigate : ( ) => { }
@@ -19,14 +22,14 @@ describe('AuthGuard', () => {
1922
2023 it ( `Should properly call 'canActivate'` , ( ) => {
2124 const authGuard = new AuthGuard ( mockRouter , mockUserService ) ;
22- const mockSpy = jasmine . createSpy ( 'mockSpy' ) ;
25+ const mockSpy = vi . fn ( ) ;
2326 expect ( authGuard . canActivate ( mockSpy as any , mockSpy as any ) ) . toEqual ( true ) ;
2427 } ) ;
2528 it ( `Should properly call 'canActivate'` , ( ) => {
2629 const authGuard = new AuthGuard ( mockRouter , mockUserService ) ;
27- const mockSpy = jasmine . createSpy ( 'mockSpy' ) ;
30+ const mockSpy = vi . fn ( ) ;
2831 mockUserService . currentUser = false ;
29- spyOn ( mockRouter , 'navigate' ) ;
32+ vi . spyOn ( mockRouter , 'navigate' ) ;
3033 expect ( authGuard . canActivate ( mockSpy as any , { url : 'test' } as any ) ) . toEqual ( false ) ;
3134 expect ( mockRouter . navigate ) . toHaveBeenCalled ( ) ;
3235 expect ( mockRouter . navigate ) . toHaveBeenCalledWith ( [ '' ] , { queryParams : { returnUrl : 'test' } } ) ;
0 commit comments