]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/health-color.pipe.spec.ts
import ceph pacific 16.2.5
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / pipes / health-color.pipe.spec.ts
1 import { CssHelper } from '~/app/shared/classes/css-helper';
2 import { HealthColorPipe } from '~/app/shared/pipes/health-color.pipe';
3
4 class CssHelperStub extends CssHelper {
5 propertyValue(propertyName: string) {
6 if (propertyName === 'health-color-healthy') {
7 return 'fakeGreen';
8 }
9 if (propertyName === 'health-color-warning') {
10 return 'fakeOrange';
11 }
12 if (propertyName === 'health-color-error') {
13 return 'fakeRed';
14 }
15 return '';
16 }
17 }
18
19 describe('HealthColorPipe', () => {
20 const pipe = new HealthColorPipe(new CssHelperStub());
21
22 it('create an instance', () => {
23 expect(pipe).toBeTruthy();
24 });
25
26 it('transforms "HEALTH_OK"', () => {
27 expect(pipe.transform('HEALTH_OK')).toEqual({
28 color: 'fakeGreen'
29 });
30 });
31
32 it('transforms "HEALTH_WARN"', () => {
33 expect(pipe.transform('HEALTH_WARN')).toEqual({
34 color: 'fakeOrange'
35 });
36 });
37
38 it('transforms "HEALTH_ERR"', () => {
39 expect(pipe.transform('HEALTH_ERR')).toEqual({
40 color: 'fakeRed'
41 });
42 });
43
44 it('transforms others', () => {
45 expect(pipe.transform('abc')).toBe(null);
46 });
47 });