]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/pg-category.service.spec.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / shared / pg-category.service.spec.ts
CommitLineData
11fdf7f2
TL
1import { TestBed } from '@angular/core/testing';
2
3import { configureTestBed } from '../../../testing/unit-test-helper';
4import { PgCategory } from './pg-category.model';
5import { PgCategoryService } from './pg-category.service';
6
7describe('PgCategoryService', () => {
8 let service: PgCategoryService;
9
10 configureTestBed({
11 providers: [PgCategoryService]
12 });
13
14 beforeEach(() => {
15 service = TestBed.get(PgCategoryService);
16 });
17
18 it('should be created', () => {
19 expect(service).toBeTruthy();
20 });
21
22 it('returns all category types', () => {
23 const categoryTypes = service.getAllTypes();
24
25 expect(categoryTypes).toEqual(PgCategory.VALID_CATEGORIES);
26 });
27
28 describe('getTypeByStates', () => {
9f95a23c 29 const testMethod = (value: string, expected: string) =>
11fdf7f2
TL
30 expect(service.getTypeByStates(value)).toEqual(expected);
31
32 it(PgCategory.CATEGORY_CLEAN, () => {
33 testMethod('clean', PgCategory.CATEGORY_CLEAN);
34 });
35
36 it(PgCategory.CATEGORY_WORKING, () => {
37 testMethod('clean+scrubbing', PgCategory.CATEGORY_WORKING);
38 testMethod(
39 ' 8 active+clean+scrubbing+deep, 255 active+clean ',
40 PgCategory.CATEGORY_WORKING
41 );
42 });
43
44 it(PgCategory.CATEGORY_WARNING, () => {
45 testMethod('clean+scrubbing+down', PgCategory.CATEGORY_WARNING);
46 testMethod('clean+scrubbing+down+nonMappedState', PgCategory.CATEGORY_WARNING);
47 });
48
49 it(PgCategory.CATEGORY_UNKNOWN, () => {
50 testMethod('clean+scrubbing+nonMappedState', PgCategory.CATEGORY_UNKNOWN);
51 testMethod('nonMappedState', PgCategory.CATEGORY_UNKNOWN);
52 testMethod('', PgCategory.CATEGORY_UNKNOWN);
53 });
54 });
55});