]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-details/nfs-details.component.spec.ts
import ceph nautilus 14.2.2
[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) => 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.selection.update();
55 component.ngOnChanges();
56 fixture.detectChanges();
57 });
58
59 it('should create', () => {
60 expect(component.data).toBeTruthy();
61 });
62
63 it('should prepare data', () => {
64 expect(component.data).toEqual({
65 'Access Type': 'RW',
66 'CephFS Filesystem': 1,
67 'CephFS User': 'fs',
68 Cluster: 'cluster1',
69 Daemons: ['node1', 'node2'],
70 'NFS Protocol': ['NFSv3', 'NFSv4'],
71 Path: '/qwe',
72 Pseudo: '/qwe',
73 'Security Label': undefined,
74 Squash: 'no_root_squash',
75 'Storage Backend': 'CephFS',
76 Transport: ['TCP', 'UDP']
77 });
78 });
79
80 it('should prepare data if RGW', () => {
81 const newData = _.assignIn(component.selection.first(), {
82 fsal: {
83 name: 'RGW',
84 rgw_user_id: 'rgw_user_id'
85 }
86 });
87 component.selection.selected = [newData];
88 component.selection.update();
89 component.ngOnChanges();
90 expect(component.data).toEqual({
91 'Access Type': 'RW',
92 Cluster: 'cluster1',
93 Daemons: ['node1', 'node2'],
94 'NFS Protocol': ['NFSv3', 'NFSv4'],
95 'Object Gateway User': 'rgw_user_id',
96 Path: '/qwe',
97 Pseudo: '/qwe',
98 Squash: 'no_root_squash',
99 'Storage Backend': 'Object Gateway',
100 Transport: ['TCP', 'UDP']
101 });
102 });
103
104 it('should have 1 client', () => {
105 expect(elem('li.nav-item:nth-of-type(2) span').nativeElement.textContent).toBe('Clients (1)');
106 expect(component.clients).toEqual([
107 {
108 access_type: 'RW',
109 addresses: ['192.168.0.10', '192.168.1.0/8'],
110 squash: 'root_id_squash'
111 }
112 ]);
113 });
114 });