diff options
Diffstat (limited to 'src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component.spec.ts')
-rw-r--r-- | src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component.spec.ts | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component.spec.ts new file mode 100644 index 000000000..f8c139bc9 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component.spec.ts @@ -0,0 +1,80 @@ +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ReactiveFormsModule } from '@angular/forms'; +import { RouterTestingModule } from '@angular/router/testing'; + +import { ToastrModule } from 'ngx-toastr'; + +import { LoadingPanelComponent } from '~/app/shared/components/loading-panel/loading-panel.component'; +import { SharedModule } from '~/app/shared/shared.module'; +import { configureTestBed } from '~/testing/unit-test-helper'; +import { MgrModuleFormComponent } from './mgr-module-form.component'; + +describe('MgrModuleFormComponent', () => { + let component: MgrModuleFormComponent; + let fixture: ComponentFixture<MgrModuleFormComponent>; + + configureTestBed( + { + declarations: [MgrModuleFormComponent], + imports: [ + HttpClientTestingModule, + ReactiveFormsModule, + RouterTestingModule, + SharedModule, + ToastrModule.forRoot() + ] + }, + [LoadingPanelComponent] + ); + + beforeEach(() => { + fixture = TestBed.createComponent(MgrModuleFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + describe('getValidators', () => { + it('should return ip validator for type addr', () => { + const result = component.getValidators({ type: 'addr' }); + expect(result.length).toBe(1); + }); + + it('should return required validator for types uint, int, size, secs', () => { + const types = ['uint', 'int', 'size', 'secs']; + types.forEach((type) => { + const result = component.getValidators({ type: type }); + expect(result.length).toBe(1); + }); + }); + + it('should return required, decimalNumber validators for type float', () => { + const result = component.getValidators({ type: 'float' }); + expect(result.length).toBe(2); + }); + + it('should return uuid validator for type uuid', () => { + const result = component.getValidators({ type: 'uuid' }); + expect(result.length).toBe(1); + }); + + it('should return no validator for type str', () => { + const result = component.getValidators({ type: 'str' }); + expect(result.length).toBe(0); + }); + + it('should return min validator for type str', () => { + const result = component.getValidators({ type: 'str', min: 1 }); + expect(result.length).toBe(1); + }); + + it('should return min, max validators for type str', () => { + const result = component.getValidators({ type: 'str', min: 1, max: 127 }); + expect(result.length).toBe(2); + }); + }); +}); |