]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/mds-summary.pipe.spec.ts
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / dashboard / mds-summary.pipe.spec.ts
1 import { TestBed } from '@angular/core/testing';
2
3 import { configureTestBed, i18nProviders } from '../../../testing/unit-test-helper';
4 import { MdsSummaryPipe } from './mds-summary.pipe';
5
6 describe('MdsSummaryPipe', () => {
7 let pipe: MdsSummaryPipe;
8
9 configureTestBed({
10 providers: [MdsSummaryPipe, i18nProviders]
11 });
12
13 beforeEach(() => {
14 pipe = TestBed.get(MdsSummaryPipe);
15 });
16
17 it('create an instance', () => {
18 expect(pipe).toBeTruthy();
19 });
20
21 it('transforms with 0 active and 2 standy', () => {
22 const payload = {
23 standbys: [0],
24 filesystems: [{ mdsmap: { info: [{ state: 'up:standby-replay' }] } }]
25 };
26 const expected = [
27 { class: '', content: '0 active' },
28 { class: 'card-text-line-break', content: '' },
29 { class: '', content: '2 standby' }
30 ];
31
32 expect(pipe.transform(payload)).toEqual(expected);
33 });
34
35 it('transforms with 1 active and 1 standy', () => {
36 const payload = {
37 standbys: [0],
38 filesystems: [{ mdsmap: { info: [{ state: 'up:active' }] } }]
39 };
40 const expected = [
41 { class: '', content: '1 active' },
42 { class: 'card-text-line-break', content: '' },
43 { class: '', content: '1 standby' }
44 ];
45 expect(pipe.transform(payload)).toEqual(expected);
46 });
47
48 it('transforms with 0 filesystems', () => {
49 const payload = {
50 standbys: [0],
51 filesystems: []
52 };
53 const expected = [{ class: '', content: 'no filesystems' }];
54
55 expect(pipe.transform(payload)).toEqual(expected);
56 });
57
58 it('transforms without filesystem', () => {
59 const payload = { standbys: [0] };
60 const expected = [
61 { class: '', content: '1 up' },
62 { class: 'card-text-line-break', content: '' },
63 { class: '', content: 'no filesystems' }
64 ];
65
66 expect(pipe.transform(payload)).toEqual(expected);
67 });
68
69 it('transforms without value', () => {
70 expect(pipe.transform(undefined)).toBe('');
71 });
72 });