1 import { TestBed } from '@angular/core/testing';
3 import { configureTestBed } from '~/testing/unit-test-helper';
4 import { MdsSummaryPipe } from './mds-summary.pipe';
6 describe('MdsSummaryPipe', () => {
7 let pipe: MdsSummaryPipe;
10 providers: [MdsSummaryPipe]
14 pipe = TestBed.inject(MdsSummaryPipe);
17 it('create an instance', () => {
18 expect(pipe).toBeTruthy();
21 it('transforms with 0 active and 2 standy', () => {
23 standbys: [{ name: 'a' }],
24 filesystems: [{ mdsmap: { info: [{ state: 'up:standby-replay' }] } }]
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' }
32 expect(pipe.transform(payload)).toEqual(expected);
35 it('transforms with 1 active and 1 standy', () => {
37 standbys: [{ name: 'b' }],
38 filesystems: [{ mdsmap: { info: [{ state: 'up:active', name: 'a' }] } }]
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' }
45 expect(pipe.transform(payload)).toEqual(expected);
48 it('transforms with 0 filesystems', () => {
49 const payload: Record<string, any> = {
53 const expected = [{ class: 'popover-info', content: 'no filesystems', titleText: '' }];
55 expect(pipe.transform(payload)).toEqual(expected);
58 it('transforms without filesystem', () => {
59 const payload = { standbys: [{ name: 'a' }] };
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' }
66 expect(pipe.transform(payload)).toEqual(expected);
69 it('transforms without value', () => {
70 expect(pipe.transform(undefined)).toBe('');