]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/mgr-summary.pipe.spec.ts
8bc2753808e5eb47cf9b932c63331bfc4a07c006
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / dashboard / mgr-summary.pipe.spec.ts
1 import { TestBed } from '@angular/core/testing';
2
3 import { configureTestBed } from '~/testing/unit-test-helper';
4 import { MgrSummaryPipe } from './mgr-summary.pipe';
5
6 describe('MgrSummaryPipe', () => {
7 let pipe: MgrSummaryPipe;
8
9 configureTestBed({
10 providers: [MgrSummaryPipe]
11 });
12
13 beforeEach(() => {
14 pipe = TestBed.inject(MgrSummaryPipe);
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 with active_name undefined', () => {
26 const payload: Record<string, any> = {
27 active_name: undefined,
28 standbys: []
29 };
30 const expected = [
31 { class: 'popover-info', content: 'n/a active', titleText: '' },
32 { class: 'card-text-line-break', content: '', titleText: '' },
33 { class: 'popover-info', content: '0 standby', titleText: '' }
34 ];
35
36 expect(pipe.transform(payload)).toEqual(expected);
37 });
38
39 it('transforms with 1 active and 2 standbys', () => {
40 const payload = {
41 active_name: 'x',
42 standbys: [{ name: 'y' }, { name: 'z' }]
43 };
44 const expected = [
45 { class: 'popover-info', content: '1 active', titleText: 'active daemon: x' },
46 { class: 'card-text-line-break', content: '', titleText: '' },
47 { class: 'popover-info', content: '2 standby', titleText: 'standby daemons: y, z' }
48 ];
49
50 expect(pipe.transform(payload)).toEqual(expected);
51 });
52 });