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