]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import { NotificationType } from '../enum/notification-type.enum'; |
2 | import { CdNotification, CdNotificationConfig } from './cd-notification'; | |
3 | ||
4 | describe('cd-notification classes', () => { | |
5 | const expectObject = (something: object, expected: object) => { | |
6 | Object.keys(expected).forEach((key) => expect(something[key]).toBe(expected[key])); | |
7 | }; | |
8 | ||
9 | // As these Models have a view methods they need to be tested | |
10 | describe('CdNotificationConfig', () => { | |
11 | it('should create a new config without any parameters', () => { | |
12 | expectObject(new CdNotificationConfig(), { | |
13 | application: 'Ceph', | |
14 | applicationClass: 'ceph-icon', | |
15 | message: undefined, | |
16 | options: undefined, | |
17 | title: undefined, | |
18 | type: 1 | |
19 | }); | |
20 | }); | |
21 | ||
22 | it('should create a new config with parameters', () => { | |
23 | expectObject( | |
24 | new CdNotificationConfig( | |
25 | NotificationType.error, | |
26 | 'Some Alert', | |
27 | 'Something failed', | |
28 | undefined, | |
29 | 'Prometheus' | |
30 | ), | |
31 | { | |
32 | application: 'Prometheus', | |
33 | applicationClass: 'prometheus-icon', | |
34 | message: 'Something failed', | |
35 | options: undefined, | |
36 | title: 'Some Alert', | |
37 | type: 0 | |
38 | } | |
39 | ); | |
40 | }); | |
41 | }); | |
42 | ||
43 | describe('CdNotification', () => { | |
44 | beforeEach(() => { | |
45 | const baseTime = new Date('2022-02-22'); | |
46 | spyOn(global, 'Date').and.returnValue(baseTime); | |
47 | }); | |
48 | ||
49 | it('should create a new config without any parameters', () => { | |
50 | expectObject(new CdNotification(), { | |
51 | application: 'Ceph', | |
52 | applicationClass: 'ceph-icon', | |
9f95a23c | 53 | iconClass: 'fa fa-info', |
11fdf7f2 TL |
54 | message: undefined, |
55 | options: undefined, | |
56 | textClass: 'text-info', | |
57 | timestamp: '2022-02-22T00:00:00.000Z', | |
58 | title: undefined, | |
59 | type: 1 | |
60 | }); | |
61 | }); | |
62 | ||
63 | it('should create a new config with parameters', () => { | |
64 | expectObject( | |
65 | new CdNotification( | |
66 | new CdNotificationConfig( | |
67 | NotificationType.error, | |
68 | 'Some Alert', | |
69 | 'Something failed', | |
70 | undefined, | |
71 | 'Prometheus' | |
72 | ) | |
73 | ), | |
74 | { | |
75 | application: 'Prometheus', | |
76 | applicationClass: 'prometheus-icon', | |
9f95a23c | 77 | iconClass: 'fa fa-exclamation-triangle', |
11fdf7f2 TL |
78 | message: 'Something failed', |
79 | options: undefined, | |
80 | textClass: 'text-danger', | |
81 | timestamp: '2022-02-22T00:00:00.000Z', | |
82 | title: 'Some Alert', | |
83 | type: 0 | |
84 | } | |
85 | ); | |
86 | }); | |
87 | ||
88 | it('should expect the right success classes', () => { | |
89 | expectObject(new CdNotification(new CdNotificationConfig(NotificationType.success)), { | |
9f95a23c | 90 | iconClass: 'fa fa-check', |
11fdf7f2 TL |
91 | textClass: 'text-success' |
92 | }); | |
93 | }); | |
94 | }); | |
95 | }); |