]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/pg-category.service.spec.ts
import ceph quincy 17.2.1
[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
f67539c2 3import { configureTestBed } from '~/testing/unit-test-helper';
11fdf7f2
TL
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(() => {
f67539c2 15 service = TestBed.inject(PgCategoryService);
11fdf7f2
TL
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);
33c7a0ef 38 testMethod('active+clean+snaptrim_wait', PgCategory.CATEGORY_WORKING);
11fdf7f2
TL
39 testMethod(
40 ' 8 active+clean+scrubbing+deep, 255 active+clean ',
41 PgCategory.CATEGORY_WORKING
42 );
43 });
44
45 it(PgCategory.CATEGORY_WARNING, () => {
46 testMethod('clean+scrubbing+down', PgCategory.CATEGORY_WARNING);
47 testMethod('clean+scrubbing+down+nonMappedState', PgCategory.CATEGORY_WARNING);
48 });
49
50 it(PgCategory.CATEGORY_UNKNOWN, () => {
51 testMethod('clean+scrubbing+nonMappedState', PgCategory.CATEGORY_UNKNOWN);
52 testMethod('nonMappedState', PgCategory.CATEGORY_UNKNOWN);
53 testMethod('', PgCategory.CATEGORY_UNKNOWN);
54 });
55 });
56});