1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { FormControl, ReactiveFormsModule } from '@angular/forms';
5 import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
6 import { CdFormBuilder } from '../../../shared/forms/cd-form-builder';
7 import { CdFormGroup } from '../../../shared/forms/cd-form-group';
8 import { SharedModule } from '../../../shared/shared.module';
9 import { NfsFormClientComponent } from './nfs-form-client.component';
11 describe('NfsFormClientComponent', () => {
12 let component: NfsFormClientComponent;
13 let fixture: ComponentFixture<NfsFormClientComponent>;
16 declarations: [NfsFormClientComponent],
17 imports: [ReactiveFormsModule, SharedModule, HttpClientTestingModule],
18 providers: i18nProviders
22 fixture = TestBed.createComponent(NfsFormClientComponent);
23 const formBuilder = TestBed.get(CdFormBuilder);
24 component = fixture.componentInstance;
26 component.form = new CdFormGroup({
27 access_type: new FormControl(''),
28 clients: formBuilder.array([]),
29 squash: new FormControl('')
32 fixture.detectChanges();
35 it('should create', () => {
36 expect(component).toBeTruthy();
39 it('should add a client', () => {
40 expect(component.form.getValue('clients')).toEqual([]);
41 component.addClient();
42 expect(component.form.getValue('clients')).toEqual([
43 { access_type: '', addresses: '', squash: '' }
47 it('should return form access_type', () => {
48 expect(component.getNoAccessTypeDescr()).toBe('-- Select the access type --');
50 component.form.patchValue({ access_type: 'RW' });
51 expect(component.getNoAccessTypeDescr()).toBe('RW (inherited from global config)');
54 it('should return form squash', () => {
55 expect(component.getNoSquashDescr()).toBe(
56 '-- Select what kind of user id squashing is performed --'
59 component.form.patchValue({ squash: 'root_id_squash' });
60 expect(component.getNoSquashDescr()).toBe('root_id_squash (inherited from global config)');
63 it('should remove client', () => {
64 component.addClient();
65 expect(component.form.getValue('clients')).toEqual([
66 { access_type: '', addresses: '', squash: '' }
69 component.removeClient(0);
70 expect(component.form.getValue('clients')).toEqual([]);