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';
6 import { ToastrModule } from 'ngx-toastr';
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';
13 describe('MgrModuleFormComponent', () => {
14 let component: MgrModuleFormComponent;
15 let fixture: ComponentFixture<MgrModuleFormComponent>;
19 declarations: [MgrModuleFormComponent],
21 HttpClientTestingModule,
25 ToastrModule.forRoot()
28 [LoadingPanelComponent]
32 fixture = TestBed.createComponent(MgrModuleFormComponent);
33 component = fixture.componentInstance;
34 fixture.detectChanges();
37 it('should create', () => {
38 expect(component).toBeTruthy();
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);
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);
55 it('should return required, decimalNumber validators for type float', () => {
56 const result = component.getValidators({ type: 'float' });
57 expect(result.length).toBe(2);
60 it('should return uuid validator for type uuid', () => {
61 const result = component.getValidators({ type: 'uuid' });
62 expect(result.length).toBe(1);
65 it('should return no validator for type str', () => {
66 const result = component.getValidators({ type: 'str' });
67 expect(result.length).toBe(0);
70 it('should return min validator for type str', () => {
71 const result = component.getValidators({ type: 'str', min: 1 });
72 expect(result.length).toBe(1);
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);