]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component.spec.ts
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / mgr-modules / mgr-module-form / mgr-module-form.component.spec.ts
CommitLineData
11fdf7f2
TL
1import { HttpClientTestingModule } from '@angular/common/http/testing';
2import { ComponentFixture, TestBed } from '@angular/core/testing';
3import { ReactiveFormsModule } from '@angular/forms';
4import { RouterTestingModule } from '@angular/router/testing';
5
494da23a 6import { ToastrModule } from 'ngx-toastr';
11fdf7f2 7
f67539c2
TL
8import { LoadingPanelComponent } from '~/app/shared/components/loading-panel/loading-panel.component';
9import { SharedModule } from '~/app/shared/shared.module';
10import { configureTestBed } from '~/testing/unit-test-helper';
11fdf7f2
TL
11import { MgrModuleFormComponent } from './mgr-module-form.component';
12
13describe('MgrModuleFormComponent', () => {
14 let component: MgrModuleFormComponent;
15 let fixture: ComponentFixture<MgrModuleFormComponent>;
16
f67539c2
TL
17 configureTestBed(
18 {
19 declarations: [MgrModuleFormComponent],
20 imports: [
21 HttpClientTestingModule,
22 ReactiveFormsModule,
23 RouterTestingModule,
24 SharedModule,
25 ToastrModule.forRoot()
26 ]
27 },
28 [LoadingPanelComponent]
29 );
11fdf7f2
TL
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 number, required validators 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(2);
52 });
53 });
54
55 it('should return number, required, min validators for types uint, int, size, secs', () => {
56 const types = ['uint', 'int', 'size', 'secs'];
57 types.forEach((type) => {
58 const result = component.getValidators({ type: type, min: 2 });
59 expect(result.length).toBe(3);
60 });
61 });
62
63 it('should return number, required, min, max validators for types uint, int, size, secs', () => {
64 const types = ['uint', 'int', 'size', 'secs'];
65 types.forEach((type) => {
66 const result = component.getValidators({ type: type, min: 2, max: 5 });
67 expect(result.length).toBe(4);
68 });
69 });
70
71 it('should return required, decimalNumber validators for type float', () => {
72 const result = component.getValidators({ type: 'float' });
73 expect(result.length).toBe(2);
74 });
75
76 it('should return uuid validator for type uuid', () => {
77 const result = component.getValidators({ type: 'uuid' });
78 expect(result.length).toBe(1);
79 });
80
81 it('should return no validator for type str', () => {
82 const result = component.getValidators({ type: 'str' });
83 expect(result.length).toBe(0);
84 });
85
86 it('should return min validator for type str', () => {
87 const result = component.getValidators({ type: 'str', min: 1 });
88 expect(result.length).toBe(1);
89 });
90
91 it('should return min, max validators for type str', () => {
92 const result = component.getValidators({ type: 'str', min: 1, max: 127 });
93 expect(result.length).toBe(2);
94 });
95 });
96});