]>
Commit | Line | Data |
---|---|---|
11fdf7f2 | 1 | import { TestBed } from '@angular/core/testing'; |
f67539c2 TL |
2 | |
3 | import { configureTestBed } from '~/testing/unit-test-helper'; | |
11fdf7f2 TL |
4 | import { OsdSummaryPipe } from './osd-summary.pipe'; |
5 | ||
6 | describe('OsdSummaryPipe', () => { | |
7 | let pipe: OsdSummaryPipe; | |
8 | ||
9 | configureTestBed({ | |
f67539c2 | 10 | providers: [OsdSummaryPipe] |
11fdf7f2 TL |
11 | }); |
12 | ||
13 | beforeEach(() => { | |
f67539c2 | 14 | pipe = TestBed.inject(OsdSummaryPipe); |
11fdf7f2 TL |
15 | }); |
16 | ||
17 | it('create an instance', () => { | |
18 | expect(pipe).toBeTruthy(); | |
19 | }); | |
20 | ||
21 | it('transforms without value', () => { | |
22 | expect(pipe.transform(undefined)).toBe(''); | |
23 | }); | |
24 | ||
25 | it('transforms having 3 osd with 3 up, 3 in, 0 down, 0 out', () => { | |
26 | const value = { | |
801d1391 | 27 | osds: [ |
20effc67 TL |
28 | { up: 1, in: 1, state: ['up', 'exists'] }, |
29 | { up: 1, in: 1, state: ['up', 'exists'] }, | |
30 | { up: 1, in: 1, state: ['up', 'exists'] } | |
801d1391 | 31 | ] |
11fdf7f2 TL |
32 | }; |
33 | expect(pipe.transform(value)).toEqual([ | |
34 | { | |
35 | content: '3 total', | |
36 | class: '' | |
37 | }, | |
38 | { | |
39 | content: '', | |
40 | class: 'card-text-line-break' | |
41 | }, | |
42 | { | |
43 | content: '3 up, 3 in', | |
44 | class: '' | |
45 | } | |
46 | ]); | |
47 | }); | |
48 | ||
b3b6e05e | 49 | it('transforms having 3 osd with 2 up, 1 in, 1 down, 2 out', () => { |
11fdf7f2 | 50 | const value = { |
801d1391 | 51 | osds: [ |
20effc67 TL |
52 | { up: 1, in: 1, state: ['up', 'exists'] }, |
53 | { up: 1, in: 0, state: ['up', 'exists'] }, | |
54 | { up: 0, in: 0, state: ['exists'] } | |
801d1391 | 55 | ] |
11fdf7f2 TL |
56 | }; |
57 | expect(pipe.transform(value)).toEqual([ | |
58 | { | |
59 | content: '3 total', | |
60 | class: '' | |
61 | }, | |
62 | { | |
63 | content: '', | |
64 | class: 'card-text-line-break' | |
65 | }, | |
66 | { | |
67 | content: '2 up, 1 in', | |
68 | class: '' | |
69 | }, | |
70 | { | |
71 | content: '', | |
72 | class: 'card-text-line-break' | |
73 | }, | |
74 | { | |
b3b6e05e | 75 | content: '1 down, 2 out', |
11fdf7f2 TL |
76 | class: 'card-text-error' |
77 | } | |
78 | ]); | |
79 | }); | |
80 | ||
20effc67 | 81 | it('transforms having 3 osd with 2 up, 3 in, 1 full, 1 nearfull, 1 down, 0 out', () => { |
11fdf7f2 | 82 | const value = { |
801d1391 | 83 | osds: [ |
20effc67 TL |
84 | { up: 1, in: 1, state: ['up', 'nearfull'] }, |
85 | { up: 1, in: 1, state: ['up', 'exists'] }, | |
86 | { up: 0, in: 1, state: ['full'] } | |
801d1391 | 87 | ] |
11fdf7f2 TL |
88 | }; |
89 | expect(pipe.transform(value)).toEqual([ | |
90 | { | |
91 | content: '3 total', | |
92 | class: '' | |
93 | }, | |
94 | { | |
95 | content: '', | |
96 | class: 'card-text-line-break' | |
97 | }, | |
98 | { | |
b3b6e05e | 99 | content: '2 up, 3 in', |
11fdf7f2 TL |
100 | class: '' |
101 | }, | |
102 | { | |
103 | content: '', | |
104 | class: 'card-text-line-break' | |
105 | }, | |
106 | { | |
107 | content: '1 down', | |
108 | class: 'card-text-error' | |
20effc67 TL |
109 | }, |
110 | { | |
111 | content: '', | |
112 | class: 'card-text-line-break' | |
113 | }, | |
114 | { | |
115 | content: '1 near full', | |
116 | class: 'card-text-error' | |
117 | }, | |
118 | { | |
119 | content: '', | |
120 | class: 'card-text-line-break' | |
121 | }, | |
122 | { | |
123 | content: '1 full', | |
124 | class: 'card-text-error' | |
11fdf7f2 TL |
125 | } |
126 | ]); | |
127 | }); | |
128 | ||
129 | it('transforms having 3 osd with 3 up, 2 in, 0 down, 1 out', () => { | |
130 | const value = { | |
801d1391 | 131 | osds: [ |
20effc67 TL |
132 | { up: 1, in: 1, state: ['up', 'exists'] }, |
133 | { up: 1, in: 1, state: ['up', 'exists'] }, | |
134 | { up: 1, in: 0, state: ['up', 'exists'] } | |
801d1391 | 135 | ] |
11fdf7f2 TL |
136 | }; |
137 | expect(pipe.transform(value)).toEqual([ | |
138 | { | |
139 | content: '3 total', | |
140 | class: '' | |
141 | }, | |
142 | { | |
143 | content: '', | |
144 | class: 'card-text-line-break' | |
145 | }, | |
146 | { | |
147 | content: '3 up, 2 in', | |
148 | class: '' | |
149 | }, | |
150 | { | |
151 | content: '', | |
152 | class: 'card-text-line-break' | |
153 | }, | |
154 | { | |
155 | content: '1 out', | |
156 | class: 'card-text-error' | |
157 | } | |
158 | ]); | |
159 | }); | |
b3b6e05e TL |
160 | |
161 | it('transforms having 4 osd with 3 up, 2 in, 1 down, another 2 out', () => { | |
162 | const value = { | |
163 | osds: [ | |
20effc67 TL |
164 | { up: 1, in: 1, state: ['up', 'exists'] }, |
165 | { up: 1, in: 0, state: ['up', 'exists'] }, | |
166 | { up: 1, in: 0, state: ['up', 'exists'] }, | |
167 | { up: 0, in: 1, state: ['exists'] } | |
b3b6e05e TL |
168 | ] |
169 | }; | |
170 | expect(pipe.transform(value)).toEqual([ | |
171 | { | |
172 | content: '4 total', | |
173 | class: '' | |
174 | }, | |
175 | { | |
176 | content: '', | |
177 | class: 'card-text-line-break' | |
178 | }, | |
179 | { | |
180 | content: '3 up, 2 in', | |
181 | class: '' | |
182 | }, | |
183 | { | |
184 | content: '', | |
185 | class: 'card-text-line-break' | |
186 | }, | |
187 | { | |
188 | content: '1 down, 2 out', | |
189 | class: 'card-text-error' | |
190 | } | |
191 | ]); | |
192 | }); | |
11fdf7f2 | 193 | }); |