]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import { AuthStorageService } from './auth-storage.service'; |
2 | ||
3 | describe('AuthStorageService', () => { | |
4 | let service: AuthStorageService; | |
5 | const username = 'foobar'; | |
6 | ||
7 | beforeEach(() => { | |
8 | service = new AuthStorageService(); | |
9 | }); | |
10 | ||
11 | it('should be created', () => { | |
12 | expect(service).toBeTruthy(); | |
13 | }); | |
14 | ||
15 | it('should store username', () => { | |
16 | service.set(username, ''); | |
17 | expect(localStorage.getItem('dashboard_username')).toBe(username); | |
18 | }); | |
19 | ||
20 | it('should remove username', () => { | |
21 | service.set(username, ''); | |
22 | service.remove(); | |
23 | expect(localStorage.getItem('dashboard_username')).toBe(null); | |
24 | }); | |
25 | ||
26 | it('should be loggedIn', () => { | |
27 | service.set(username, ''); | |
28 | expect(service.isLoggedIn()).toBe(true); | |
29 | }); | |
30 | ||
31 | it('should not be loggedIn', () => { | |
32 | service.remove(); | |
33 | expect(service.isLoggedIn()).toBe(false); | |
34 | }); | |
9f95a23c TL |
35 | |
36 | it('should be SSO', () => { | |
37 | service.set(username, '', {}, true); | |
38 | expect(localStorage.getItem('sso')).toBe('true'); | |
39 | expect(service.isSSO()).toBe(true); | |
40 | }); | |
41 | ||
42 | it('should not be SSO', () => { | |
43 | service.set(username, ''); | |
44 | expect(localStorage.getItem('sso')).toBe('false'); | |
45 | expect(service.isSSO()).toBe(false); | |
46 | }); | |
11fdf7f2 | 47 | }); |