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