]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/osd-summary.pipe.spec.ts
update source to Ceph Pacific 16.2.2
[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
3 import { configureTestBed } from '~/testing/unit-test-helper';
4 import { OsdSummaryPipe } from './osd-summary.pipe';
5
6 describe('OsdSummaryPipe', () => {
7 let pipe: OsdSummaryPipe;
8
9 configureTestBed({
10 providers: [OsdSummaryPipe]
11 });
12
13 beforeEach(() => {
14 pipe = TestBed.inject(OsdSummaryPipe);
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 = {
27 osds: [
28 { up: 1, in: 1 },
29 { up: 1, in: 1 },
30 { up: 1, in: 1 }
31 ]
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
49 it('transforms having 3 osd with 2 up, 1 in, 1 down, 1 out', () => {
50 const value = {
51 osds: [
52 { up: 1, in: 1 },
53 { up: 1, in: 0 },
54 { up: 0, in: 0 }
55 ]
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 {
75 content: '1 down, 1 out',
76 class: 'card-text-error'
77 }
78 ]);
79 });
80
81 it('transforms having 3 osd with 2 up, 2 in, 1 down, 0 out', () => {
82 const value = {
83 osds: [
84 { up: 1, in: 1 },
85 { up: 1, in: 1 },
86 { up: 0, in: 0 }
87 ]
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 {
99 content: '2 up, 2 in',
100 class: ''
101 },
102 {
103 content: '',
104 class: 'card-text-line-break'
105 },
106 {
107 content: '1 down',
108 class: 'card-text-error'
109 }
110 ]);
111 });
112
113 it('transforms having 3 osd with 3 up, 2 in, 0 down, 1 out', () => {
114 const value = {
115 osds: [
116 { up: 1, in: 1 },
117 { up: 1, in: 1 },
118 { up: 1, in: 0 }
119 ]
120 };
121 expect(pipe.transform(value)).toEqual([
122 {
123 content: '3 total',
124 class: ''
125 },
126 {
127 content: '',
128 class: 'card-text-line-break'
129 },
130 {
131 content: '3 up, 2 in',
132 class: ''
133 },
134 {
135 content: '',
136 class: 'card-text-line-break'
137 },
138 {
139 content: '1 out',
140 class: 'card-text-error'
141 }
142 ]);
143 });
144 });