]> git.apps.os.sepia.ceph.com Git - ceph.git/blob
6666731d359613192e225741b5b7876d5a8a6ba6
[ceph.git] /
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';
10 import { IscsiTargetIqnSettingsModalComponent } from './iscsi-target-iqn-settings-modal.component';
11
12 describe('IscsiTargetIqnSettingsModalComponent', () => {
13   let component: IscsiTargetIqnSettingsModalComponent;
14   let fixture: ComponentFixture<IscsiTargetIqnSettingsModalComponent>;
15
16   configureTestBed({
17     declarations: [IscsiTargetIqnSettingsModalComponent],
18     imports: [SharedModule, ReactiveFormsModule, HttpClientTestingModule, RouterTestingModule],
19     providers: [BsModalRef, i18nProviders]
20   });
21
22   beforeEach(() => {
23     fixture = TestBed.createComponent(IscsiTargetIqnSettingsModalComponent);
24     component = fixture.componentInstance;
25     component.target_controls = new FormControl({});
26     component.target_default_controls = {
27       cmdsn_depth: 1,
28       dataout_timeout: 2,
29       first_burst_length: 'Yes'
30     };
31     component.ngOnInit();
32     fixture.detectChanges();
33   });
34
35   it('should create', () => {
36     expect(component).toBeTruthy();
37   });
38
39   it('should fill the settingsForm', () => {
40     expect(component.settingsForm.value).toEqual({
41       cmdsn_depth: null,
42       dataout_timeout: null,
43       first_burst_length: null
44     });
45   });
46
47   it('should save changes to target_controls', () => {
48     component.settingsForm.patchValue({ dataout_timeout: 1234 });
49     expect(component.target_controls.value).toEqual({});
50     component.save();
51     expect(component.target_controls.value).toEqual({ dataout_timeout: 1234 });
52   });
53 });