]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import { HttpClientTestingModule } from '@angular/common/http/testing'; |
2 | import { ComponentFixture, TestBed } from '@angular/core/testing'; | |
3 | import { FormControl, ReactiveFormsModule } from '@angular/forms'; | |
4 | import { RouterTestingModule } from '@angular/router/testing'; | |
5 | ||
6 | import { BsModalRef } from 'ngx-bootstrap/modal'; | |
7 | ||
8 | import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper'; | |
9 | import { SharedModule } from '../../../shared/shared.module'; | |
eafe8130 | 10 | import { IscsiSettingComponent } from '../iscsi-setting/iscsi-setting.component'; |
11fdf7f2 TL |
11 | import { IscsiTargetIqnSettingsModalComponent } from './iscsi-target-iqn-settings-modal.component'; |
12 | ||
13 | describe('IscsiTargetIqnSettingsModalComponent', () => { | |
14 | let component: IscsiTargetIqnSettingsModalComponent; | |
15 | let fixture: ComponentFixture<IscsiTargetIqnSettingsModalComponent>; | |
16 | ||
17 | configureTestBed({ | |
eafe8130 | 18 | declarations: [IscsiTargetIqnSettingsModalComponent, IscsiSettingComponent], |
11fdf7f2 TL |
19 | imports: [SharedModule, ReactiveFormsModule, HttpClientTestingModule, RouterTestingModule], |
20 | providers: [BsModalRef, i18nProviders] | |
21 | }); | |
22 | ||
23 | beforeEach(() => { | |
24 | fixture = TestBed.createComponent(IscsiTargetIqnSettingsModalComponent); | |
25 | component = fixture.componentInstance; | |
26 | component.target_controls = new FormControl({}); | |
27 | component.target_default_controls = { | |
28 | cmdsn_depth: 1, | |
29 | dataout_timeout: 2, | |
eafe8130 TL |
30 | first_burst_length: true |
31 | }; | |
32 | component.target_controls_limits = { | |
33 | cmdsn_depth: { | |
34 | min: 1, | |
35 | max: 512, | |
36 | type: 'int' | |
37 | }, | |
38 | dataout_timeout: { | |
39 | min: 2, | |
40 | max: 60, | |
41 | type: 'int' | |
42 | }, | |
43 | first_burst_length: { | |
44 | max: 16777215, | |
45 | min: 512, | |
46 | type: 'int' | |
47 | } | |
11fdf7f2 TL |
48 | }; |
49 | component.ngOnInit(); | |
50 | fixture.detectChanges(); | |
51 | }); | |
52 | ||
53 | it('should create', () => { | |
54 | expect(component).toBeTruthy(); | |
55 | }); | |
56 | ||
57 | it('should fill the settingsForm', () => { | |
58 | expect(component.settingsForm.value).toEqual({ | |
59 | cmdsn_depth: null, | |
60 | dataout_timeout: null, | |
61 | first_burst_length: null | |
62 | }); | |
63 | }); | |
64 | ||
65 | it('should save changes to target_controls', () => { | |
66 | component.settingsForm.patchValue({ dataout_timeout: 1234 }); | |
67 | expect(component.target_controls.value).toEqual({}); | |
68 | component.save(); | |
69 | expect(component.target_controls.value).toEqual({ dataout_timeout: 1234 }); | |
70 | }); | |
71 | }); |