1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { TestBed } from '@angular/core/testing';
4 import { configureTestBed } from '../../../testing/unit-test-helper';
5 import { Motd } from '../api/motd.service';
6 import { MotdNotificationService } from './motd-notification.service';
8 describe('MotdNotificationService', () => {
9 let service: MotdNotificationService;
12 providers: [MotdNotificationService],
13 imports: [HttpClientTestingModule]
17 service = TestBed.get(MotdNotificationService);
20 it('should be created', () => {
21 expect(service).toBeTruthy();
24 it('should hide [1]', () => {
25 spyOn(service.motdSource, 'next');
26 spyOn(service.motdSource, 'getValue').and.returnValue({
30 md5: 'acbd18db4cc2f85cedef654fccc4a4d8'
33 expect(localStorage.getItem('dashboard_motd_hidden')).toBe(
34 'info:acbd18db4cc2f85cedef654fccc4a4d8'
36 expect(sessionStorage.getItem('dashboard_motd_hidden')).toBeNull();
37 expect(service.motdSource.next).toBeCalledWith(null);
40 it('should hide [2]', () => {
41 spyOn(service.motdSource, 'getValue').and.returnValue({
45 md5: '37b51d194a7513e45b56f6524f2d51f2'
48 expect(sessionStorage.getItem('dashboard_motd_hidden')).toBe(
49 'warning:37b51d194a7513e45b56f6524f2d51f2'
51 expect(localStorage.getItem('dashboard_motd_hidden')).toBeNull();
54 it('should process response [1]', () => {
59 md5: 'acbd18db4cc2f85cedef654fccc4a4d8'
61 spyOn(service.motdSource, 'next');
62 service.processResponse(motd);
63 expect(service.motdSource.next).toBeCalledWith(motd);
66 it('should process response [2]', () => {
71 md5: 'acbd18db4cc2f85cedef654fccc4a4d8'
73 localStorage.setItem('dashboard_motd_hidden', 'info');
74 service.processResponse(motd);
75 expect(sessionStorage.getItem('dashboard_motd_hidden')).toBeNull();
76 expect(localStorage.getItem('dashboard_motd_hidden')).toBeNull();
79 it('should process response [3]', () => {
84 md5: 'acbd18db4cc2f85cedef654fccc4a4d8'
86 spyOn(service.motdSource, 'next');
87 localStorage.setItem('dashboard_motd_hidden', 'info:acbd18db4cc2f85cedef654fccc4a4d8');
88 service.processResponse(motd);
89 expect(service.motdSource.next).not.toBeCalled();
92 it('should process response [4]', () => {
97 md5: 'acbd18db4cc2f85cedef654fccc4a4d8'
99 spyOn(service.motdSource, 'next');
100 localStorage.setItem('dashboard_motd_hidden', 'info:37b51d194a7513e45b56f6524f2d51f2');
101 service.processResponse(motd);
102 expect(service.motdSource.next).toBeCalled();
105 it('should process response [5]', () => {
110 md5: 'acbd18db4cc2f85cedef654fccc4a4d8'
112 spyOn(service.motdSource, 'next');
113 localStorage.setItem('dashboard_motd_hidden', 'danger:acbd18db4cc2f85cedef654fccc4a4d8');
114 service.processResponse(motd);
115 expect(service.motdSource.next).toBeCalled();