1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { By } from '@angular/platform-browser';
4 import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
6 import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
7 import _ from 'lodash';
9 import { SharedModule } from '~/app/shared/shared.module';
10 import { configureTestBed } from '~/testing/unit-test-helper';
11 import { NfsDetailsComponent } from './nfs-details.component';
13 describe('NfsDetailsComponent', () => {
14 let component: NfsDetailsComponent;
15 let fixture: ComponentFixture<NfsDetailsComponent>;
17 const elem = (css: string) => fixture.debugElement.query(By.css(css));
20 declarations: [NfsDetailsComponent],
21 imports: [BrowserAnimationsModule, SharedModule, HttpClientTestingModule, NgbNavModule]
25 fixture = TestBed.createComponent(NfsDetailsComponent);
26 component = fixture.componentInstance;
28 component.selection = {
31 fsal: { name: 'CEPH', user_id: 'fs', fs_name: 1 },
32 cluster_id: 'cluster1',
35 squash: 'no_root_squash',
37 transports: ['TCP', 'UDP'],
40 addresses: ['192.168.0.10', '192.168.1.0/8'],
42 squash: 'root_id_squash'
46 component.ngOnChanges();
47 fixture.detectChanges();
50 it('should create', () => {
51 expect(component.data).toBeTruthy();
54 it('should prepare data', () => {
55 expect(component.data).toEqual({
57 'CephFS Filesystem': 1,
60 'NFS Protocol': ['NFSv4'],
63 'Security Label': undefined,
64 Squash: 'no_root_squash',
65 'Storage Backend': 'CephFS',
66 Transport: ['TCP', 'UDP']
70 it('should prepare data if RGW', () => {
71 const newData = _.assignIn(component.selection, {
77 component.selection = newData;
78 component.ngOnChanges();
79 expect(component.data).toEqual({
82 'NFS Protocol': ['NFSv4'],
83 'Object Gateway User': 'user-id',
86 Squash: 'no_root_squash',
87 'Storage Backend': 'Object Gateway',
88 Transport: ['TCP', 'UDP']
92 it('should have 1 client', () => {
93 expect(elem('ul.nav-tabs li:nth-of-type(2) a').nativeElement.textContent).toBe('Clients (1)');
94 expect(component.clients).toEqual([
97 addresses: ['192.168.0.10', '192.168.1.0/8'],
98 squash: 'root_id_squash'