]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-details/nfs-details.component.spec.ts
a1d1c6d349b80c0b5e59187e3c4103481dc8d862
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / nfs / nfs-details / nfs-details.component.spec.ts
1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { By } from '@angular/platform-browser';
4
5 import * as _ from 'lodash';
6 import { TabsModule } from 'ngx-bootstrap/tabs';
7
8 import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
9 import { CdTableSelection } from '../../../shared/models/cd-table-selection';
10 import { SharedModule } from '../../../shared/shared.module';
11 import { NfsDetailsComponent } from './nfs-details.component';
12
13 describe('NfsDetailsComponent', () => {
14 let component: NfsDetailsComponent;
15 let fixture: ComponentFixture<NfsDetailsComponent>;
16
17 const elem = (css: string) => fixture.debugElement.query(By.css(css));
18
19 configureTestBed({
20 declarations: [NfsDetailsComponent],
21 imports: [SharedModule, TabsModule.forRoot(), HttpClientTestingModule],
22 providers: i18nProviders
23 });
24
25 beforeEach(() => {
26 fixture = TestBed.createComponent(NfsDetailsComponent);
27 component = fixture.componentInstance;
28
29 component.selection = new CdTableSelection();
30 component.selection.selected = [
31 {
32 export_id: 1,
33 path: '/qwe',
34 fsal: { name: 'CEPH', user_id: 'fs', fs_name: 1 },
35 cluster_id: 'cluster1',
36 daemons: ['node1', 'node2'],
37 pseudo: '/qwe',
38 tag: 'asd',
39 access_type: 'RW',
40 squash: 'no_root_squash',
41 protocols: [3, 4],
42 transports: ['TCP', 'UDP'],
43 clients: [
44 {
45 addresses: ['192.168.0.10', '192.168.1.0/8'],
46 access_type: 'RW',
47 squash: 'root_id_squash'
48 }
49 ],
50 id: 'cluster1:1',
51 state: 'LOADING'
52 }
53 ];
54 component.ngOnChanges();
55 fixture.detectChanges();
56 });
57
58 it('should create', () => {
59 expect(component.data).toBeTruthy();
60 });
61
62 it('should prepare data', () => {
63 expect(component.data).toEqual({
64 'Access Type': 'RW',
65 'CephFS Filesystem': 1,
66 'CephFS User': 'fs',
67 Cluster: 'cluster1',
68 Daemons: ['node1', 'node2'],
69 'NFS Protocol': ['NFSv3', 'NFSv4'],
70 Path: '/qwe',
71 Pseudo: '/qwe',
72 'Security Label': undefined,
73 Squash: 'no_root_squash',
74 'Storage Backend': 'CephFS',
75 Transport: ['TCP', 'UDP']
76 });
77 });
78
79 it('should prepare data if RGW', () => {
80 const newData = _.assignIn(component.selection.first(), {
81 fsal: {
82 name: 'RGW',
83 rgw_user_id: 'rgw_user_id'
84 }
85 });
86 component.selection.selected = [newData];
87 component.ngOnChanges();
88 expect(component.data).toEqual({
89 'Access Type': 'RW',
90 Cluster: 'cluster1',
91 Daemons: ['node1', 'node2'],
92 'NFS Protocol': ['NFSv3', 'NFSv4'],
93 'Object Gateway User': 'rgw_user_id',
94 Path: '/qwe',
95 Pseudo: '/qwe',
96 Squash: 'no_root_squash',
97 'Storage Backend': 'Object Gateway',
98 Transport: ['TCP', 'UDP']
99 });
100 });
101
102 it('should have 1 client', () => {
103 expect(elem('li.nav-item:nth-of-type(2) span').nativeElement.textContent).toBe('Clients (1)');
104 expect(component.clients).toEqual([
105 {
106 access_type: 'RW',
107 addresses: ['192.168.0.10', '192.168.1.0/8'],
108 squash: 'root_id_squash'
109 }
110 ]);
111 });
112 });