]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/mds-summary.pipe.spec.ts
update source to Ceph Pacific 16.2.2
[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 } 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]
11 });
12
13 beforeEach(() => {
14 pipe = TestBed.inject(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: [{ name: 'a' }],
24 filesystems: [{ mdsmap: { info: [{ state: 'up:standby-replay' }] } }]
25 };
26 const expected = [
27 { class: 'popover-info', content: '0 active', titleText: '1 standbyReplay' },
28 { class: 'card-text-line-break', content: '', titleText: '' },
29 { class: 'popover-info', content: '2 standby', titleText: 'standby daemons: a' }
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: [{ name: 'b' }],
38 filesystems: [{ mdsmap: { info: [{ state: 'up:active', name: 'a' }] } }]
39 };
40 const expected = [
41 { class: 'popover-info', content: '1 active', titleText: 'active daemon: a' },
42 { class: 'card-text-line-break', content: '', titleText: '' },
43 { class: 'popover-info', content: '1 standby', titleText: 'standby daemons: b' }
44 ];
45 expect(pipe.transform(payload)).toEqual(expected);
46 });
47
48 it('transforms with 0 filesystems', () => {
49 const payload: Record<string, any> = {
50 standbys: [0],
51 filesystems: []
52 };
53 const expected = [{ class: 'popover-info', content: 'no filesystems', titleText: '' }];
54
55 expect(pipe.transform(payload)).toEqual(expected);
56 });
57
58 it('transforms without filesystem', () => {
59 const payload = { standbys: [{ name: 'a' }] };
60 const expected = [
61 { class: 'popover-info', content: '1 up', titleText: '' },
62 { class: 'card-text-line-break', content: '', titleText: '' },
63 { class: 'popover-info', content: 'no filesystems', titleText: 'standby daemons: a' }
64 ];
65
66 expect(pipe.transform(payload)).toEqual(expected);
67 });
68
69 it('transforms without value', () => {
70 expect(pipe.transform(undefined)).toBe('');
71 });
72 });