-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc897d9
commit fd745b3
Showing
7 changed files
with
71 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,53 @@ | ||
import { provideHttpClient } from '@angular/common/http'; | ||
import { TestBed } from '@angular/core/testing'; | ||
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'; | ||
|
||
import { MessageService } from 'primeng/api'; | ||
import { of, Subject } from 'rxjs'; | ||
|
||
import { AuthService } from './auth.service'; | ||
|
||
describe('AuthService', () => { | ||
let service: AuthService; | ||
let routerEventsSubject: Subject<NavigationEnd>; | ||
|
||
beforeEach(() => { | ||
routerEventsSubject = new Subject(); | ||
|
||
TestBed.configureTestingModule({ | ||
providers: [provideHttpClient(), MessageService], | ||
providers: [ | ||
provideHttpClient(), | ||
MessageService, | ||
{ | ||
provide: ActivatedRoute, | ||
useValue: { | ||
snapshot: { queryParams: {} }, | ||
queryParams: of({}), | ||
}, | ||
}, | ||
{ | ||
provide: Router, | ||
useValue: { | ||
events: routerEventsSubject.asObservable(), | ||
navigate: jest.fn(), | ||
}, | ||
}, | ||
{ | ||
provide: Location, | ||
useValue: { | ||
back: jest.fn(), | ||
}, | ||
}, | ||
], | ||
}); | ||
service = TestBed.inject(AuthService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
|
||
it('should handle router events', () => { | ||
routerEventsSubject.next(new NavigationEnd(1, 'http://example.com', 'http://example.com')); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters