]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component.spec.ts
import ceph quincy 17.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / mgr-modules / mgr-module-form / mgr-module-form.component.spec.ts
1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { ReactiveFormsModule } from '@angular/forms';
4 import { RouterTestingModule } from '@angular/router/testing';
5
6 import { ToastrModule } from 'ngx-toastr';
7
8 import { LoadingPanelComponent } from '~/app/shared/components/loading-panel/loading-panel.component';
9 import { SharedModule } from '~/app/shared/shared.module';
10 import { configureTestBed } from '~/testing/unit-test-helper';
11 import { MgrModuleFormComponent } from './mgr-module-form.component';
12
13 describe('MgrModuleFormComponent', () => {
14 let component: MgrModuleFormComponent;
15 let fixture: ComponentFixture<MgrModuleFormComponent>;
16
17 configureTestBed(
18 {
19 declarations: [MgrModuleFormComponent],
20 imports: [
21 HttpClientTestingModule,
22 ReactiveFormsModule,
23 RouterTestingModule,
24 SharedModule,
25 ToastrModule.forRoot()
26 ]
27 },
28 [LoadingPanelComponent]
29 );
30
31 beforeEach(() => {
32 fixture = TestBed.createComponent(MgrModuleFormComponent);
33 component = fixture.componentInstance;
34 fixture.detectChanges();
35 });
36
37 it('should create', () => {
38 expect(component).toBeTruthy();
39 });
40
41 describe('getValidators', () => {
42 it('should return ip validator for type addr', () => {
43 const result = component.getValidators({ type: 'addr' });
44 expect(result.length).toBe(1);
45 });
46
47 it('should return required validator for types uint, int, size, secs', () => {
48 const types = ['uint', 'int', 'size', 'secs'];
49 types.forEach((type) => {
50 const result = component.getValidators({ type: type });
51 expect(result.length).toBe(1);
52 });
53 });
54
55 it('should return required, decimalNumber validators for type float', () => {
56 const result = component.getValidators({ type: 'float' });
57 expect(result.length).toBe(2);
58 });
59
60 it('should return uuid validator for type uuid', () => {
61 const result = component.getValidators({ type: 'uuid' });
62 expect(result.length).toBe(1);
63 });
64
65 it('should return no validator for type str', () => {
66 const result = component.getValidators({ type: 'str' });
67 expect(result.length).toBe(0);
68 });
69
70 it('should return min validator for type str', () => {
71 const result = component.getValidators({ type: 'str', min: 1 });
72 expect(result.length).toBe(1);
73 });
74
75 it('should return min, max validators for type str', () => {
76 const result = component.getValidators({ type: 'str', min: 1, max: 127 });
77 expect(result.length).toBe(2);
78 });
79 });
80 });