1 import { AuthStorageService } from './auth-storage.service';
3 describe('AuthStorageService', () => {
4 let service: AuthStorageService;
5 const username = 'foobar';
8 service = new AuthStorageService();
11 it('should be created', () => {
12 expect(service).toBeTruthy();
15 it('should store username', () => {
16 service.set(username, '');
17 expect(localStorage.getItem('dashboard_username')).toBe(username);
20 it('should remove username', () => {
21 service.set(username, '');
23 expect(localStorage.getItem('dashboard_username')).toBe(null);
26 it('should be loggedIn', () => {
27 service.set(username, '');
28 expect(service.isLoggedIn()).toBe(true);
31 it('should not be loggedIn', () => {
33 expect(service.isLoggedIn()).toBe(false);
36 it('should be SSO', () => {
37 service.set(username, {}, true);
38 expect(localStorage.getItem('sso')).toBe('true');
39 expect(service.isSSO()).toBe(true);
42 it('should not be SSO', () => {
43 service.set(username);
44 expect(localStorage.getItem('sso')).toBe('false');
45 expect(service.isSSO()).toBe(false);