]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-iqn-settings-modal/iscsi-target-iqn-settings-modal.component.spec.ts
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / block / iscsi-target-iqn-settings-modal / iscsi-target-iqn-settings-modal.component.spec.ts
CommitLineData
11fdf7f2
TL
1import { HttpClientTestingModule } from '@angular/common/http/testing';
2import { ComponentFixture, TestBed } from '@angular/core/testing';
3import { FormControl, ReactiveFormsModule } from '@angular/forms';
4import { RouterTestingModule } from '@angular/router/testing';
5
f67539c2 6import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
11fdf7f2 7
f67539c2
TL
8import { SharedModule } from '~/app/shared/shared.module';
9import { configureTestBed } from '~/testing/unit-test-helper';
eafe8130 10import { IscsiSettingComponent } from '../iscsi-setting/iscsi-setting.component';
11fdf7f2
TL
11import { IscsiTargetIqnSettingsModalComponent } from './iscsi-target-iqn-settings-modal.component';
12
13describe('IscsiTargetIqnSettingsModalComponent', () => {
14 let component: IscsiTargetIqnSettingsModalComponent;
15 let fixture: ComponentFixture<IscsiTargetIqnSettingsModalComponent>;
16
17 configureTestBed({
eafe8130 18 declarations: [IscsiTargetIqnSettingsModalComponent, IscsiSettingComponent],
11fdf7f2 19 imports: [SharedModule, ReactiveFormsModule, HttpClientTestingModule, RouterTestingModule],
f67539c2 20 providers: [NgbActiveModal]
11fdf7f2
TL
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});