2 HttpClientTestingModule,
5 } from '@angular/common/http/testing';
6 import { ComponentFixture, TestBed } from '@angular/core/testing';
7 import { ReactiveFormsModule } from '@angular/forms';
8 import { RouterTestingModule } from '@angular/router/testing';
10 import { ToastModule } from 'ng2-toastr';
11 import { BsModalRef } from 'ngx-bootstrap/modal';
13 import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
14 import { SharedModule } from '../../../shared/shared.module';
15 import { IscsiTargetDiscoveryModalComponent } from './iscsi-target-discovery-modal.component';
17 describe('IscsiTargetDiscoveryModalComponent', () => {
18 let component: IscsiTargetDiscoveryModalComponent;
19 let fixture: ComponentFixture<IscsiTargetDiscoveryModalComponent>;
20 let httpTesting: HttpTestingController;
24 declarations: [IscsiTargetDiscoveryModalComponent],
26 HttpClientTestingModule,
29 ToastModule.forRoot(),
32 providers: [i18nProviders, BsModalRef]
36 fixture = TestBed.createComponent(IscsiTargetDiscoveryModalComponent);
37 component = fixture.componentInstance;
38 httpTesting = TestBed.get(HttpTestingController);
39 fixture.detectChanges();
40 req = httpTesting.expectOne('api/iscsi/discoveryauth');
43 it('should create', () => {
44 expect(component).toBeTruthy();
47 it('should create form', () => {
48 expect(component.discoveryForm.value).toEqual({
56 it('should patch form', () => {
60 mutual_user: 'mutual_foo',
61 mutual_password: 'mutual_bar'
63 expect(component.discoveryForm.value).toEqual({
66 mutual_user: 'mutual_foo',
67 mutual_password: 'mutual_bar'
71 it('should submit new values', () => {
72 component.discoveryForm.patchValue({
75 mutual_user: 'mutual_new_user',
76 mutual_password: 'mutual_new_pass'
78 component.submitAction();
80 const submit_req = httpTesting.expectOne('api/iscsi/discoveryauth');
81 expect(submit_req.request.method).toBe('PUT');
82 expect(submit_req.request.body).toEqual({
85 mutual_user: 'mutual_new_user',
86 mutual_password: 'mutual_new_pass'