]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/mgr-summary.pipe.spec.ts
import 15.2.0 Octopus source
[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, i18nProviders } from '../../../testing/unit-test-helper';
4
5 import { MgrSummaryPipe } from './mgr-summary.pipe';
6
7 describe('MgrSummaryPipe', () => {
8 let pipe: MgrSummaryPipe;
9
10 configureTestBed({
11 providers: [MgrSummaryPipe, i18nProviders]
12 });
13
14 beforeEach(() => {
15 pipe = TestBed.get(MgrSummaryPipe);
16 });
17
18 it('create an instance', () => {
19 expect(pipe).toBeTruthy();
20 });
21
22 it('transforms without value', () => {
23 expect(pipe.transform(undefined)).toBe('');
24 });
25
26 it('transforms with active_name undefined', () => {
27 const payload: Record<string, any> = {
28 active_name: undefined,
29 standbys: []
30 };
31 const expected = [
32 { class: 'mgr-active-name', content: 'n/a active', titleText: '' },
33 { class: 'card-text-line-break', content: '', titleText: '' },
34 { class: '', content: '0 standby', titleText: '' }
35 ];
36
37 expect(pipe.transform(payload)).toEqual(expected);
38 });
39
40 it('transforms with 1 active and 2 standbys', () => {
41 const payload = {
42 active_name: 'a',
43 standbys: ['b', 'c']
44 };
45 const expected = [
46 { class: 'mgr-active-name', content: '1 active', titleText: 'active daemon: a' },
47 { class: 'card-text-line-break', content: '', titleText: '' },
48 { class: '', content: '2 standby', titleText: '' }
49 ];
50
51 expect(pipe.transform(payload)).toEqual(expected);
52 });
53 });