summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/services/rbd-configuration.service.spec.ts
blob: b119f5d63027cbf1ce3dc3165c9a1613c498c3a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { TestBed } from '@angular/core/testing';

import { configureTestBed } from '~/testing/unit-test-helper';
import { RbdConfigurationType } from '../models/configuration';
import { RbdConfigurationService } from './rbd-configuration.service';

describe('RbdConfigurationService', () => {
  let service: RbdConfigurationService;

  configureTestBed({
    providers: [RbdConfigurationService]
  });

  beforeEach(() => {
    service = TestBed.inject(RbdConfigurationService);
  });

  it('should be created', () => {
    expect(service).toBeTruthy();
  });

  it('should filter config options', () => {
    const result = service.getOptionByName('rbd_qos_write_iops_burst');
    expect(result).toEqual({
      name: 'rbd_qos_write_iops_burst',
      displayName: 'Write IOPS Burst',
      description: 'The desired burst limit of write operations.',
      type: RbdConfigurationType.iops
    });
  });

  it('should return the display name', () => {
    const displayName = service.getDisplayName('rbd_qos_write_iops_burst');
    expect(displayName).toBe('Write IOPS Burst');
  });

  it('should return the description', () => {
    const description = service.getDescription('rbd_qos_write_iops_burst');
    expect(description).toBe('The desired burst limit of write operations.');
  });

  it('should have a class for each section', () => {
    service.sections.forEach((section) => expect(section.class).toBeTruthy());
  });
});