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 { CdFormBuilder } from '~/app/shared/forms/cd-form-builder';
6 import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
7 import { SharedModule } from '~/app/shared/shared.module';
8 import { configureTestBed } from '~/testing/unit-test-helper';
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]
21 fixture = TestBed.createComponent(NfsFormClientComponent);
22 const formBuilder = TestBed.inject(CdFormBuilder);
23 component = fixture.componentInstance;
25 component.form = new CdFormGroup({
26 access_type: new FormControl(''),
27 clients: formBuilder.array([]),
28 squash: new FormControl('')
31 fixture.detectChanges();
34 it('should create', () => {
35 expect(component).toBeTruthy();
38 it('should add a client', () => {
39 expect(component.form.getValue('clients')).toEqual([]);
40 component.addClient();
41 expect(component.form.getValue('clients')).toEqual([
42 { access_type: '', addresses: '', squash: '' }
46 it('should return form access_type', () => {
47 expect(component.getNoAccessTypeDescr()).toBe('-- Select the access type --');
49 component.form.patchValue({ access_type: 'RW' });
50 expect(component.getNoAccessTypeDescr()).toBe('RW (inherited from global config)');
53 it('should return form squash', () => {
54 expect(component.getNoSquashDescr()).toBe(
55 '-- Select what kind of user id squashing is performed --'
58 component.form.patchValue({ squash: 'root_id_squash' });
59 expect(component.getNoSquashDescr()).toBe('root_id_squash (inherited from global config)');
62 it('should remove client', () => {
63 component.addClient();
64 expect(component.form.getValue('clients')).toEqual([
65 { access_type: '', addresses: '', squash: '' }
68 component.removeClient(0);
69 expect(component.form.getValue('clients')).toEqual([]);