]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/osd-summary.pipe.spec.ts
5b7010907d3408d301464ade07839b2e9fdc2edb
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / dashboard / osd-summary.pipe.spec.ts
1 import { TestBed } from '@angular/core/testing';
2 import { configureTestBed, i18nProviders } from '../../../testing/unit-test-helper';
3 import { OsdSummaryPipe } from './osd-summary.pipe';
4
5 describe('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 = {
26 osds: [
27 { up: 1, in: 1 },
28 { up: 1, in: 1 },
29 { up: 1, in: 1 }
30 ]
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
48 it('transforms having 3 osd with 2 up, 1 in, 1 down, 1 out', () => {
49 const value = {
50 osds: [
51 { up: 1, in: 1 },
52 { up: 1, in: 0 },
53 { up: 0, in: 0 }
54 ]
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 {
74 content: '1 down, 1 out',
75 class: 'card-text-error'
76 }
77 ]);
78 });
79
80 it('transforms having 3 osd with 2 up, 2 in, 1 down, 0 out', () => {
81 const value = {
82 osds: [
83 { up: 1, in: 1 },
84 { up: 1, in: 1 },
85 { up: 0, in: 0 }
86 ]
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 {
98 content: '2 up, 2 in',
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 = {
114 osds: [
115 { up: 1, in: 1 },
116 { up: 1, in: 1 },
117 { up: 1, in: 0 }
118 ]
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 });
143 });