]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-details/nfs-details.component.spec.ts
fcf5305393cba5a345a07bab57369e11bafb3d48
[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 import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
5
6 import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
7 import _ from 'lodash';
8
9 import { SharedModule } from '~/app/shared/shared.module';
10 import { configureTestBed } from '~/testing/unit-test-helper';
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: [BrowserAnimationsModule, SharedModule, HttpClientTestingModule, NgbNavModule]
22 });
23
24 beforeEach(() => {
25 fixture = TestBed.createComponent(NfsDetailsComponent);
26 component = fixture.componentInstance;
27
28 component.selection = {
29 export_id: 1,
30 path: '/qwe',
31 fsal: { name: 'CEPH', user_id: 'fs', fs_name: 1 },
32 cluster_id: 'cluster1',
33 pseudo: '/qwe',
34 access_type: 'RW',
35 squash: 'no_root_squash',
36 protocols: [4],
37 transports: ['TCP', 'UDP'],
38 clients: [
39 {
40 addresses: ['192.168.0.10', '192.168.1.0/8'],
41 access_type: 'RW',
42 squash: 'root_id_squash'
43 }
44 ]
45 };
46 component.ngOnChanges();
47 fixture.detectChanges();
48 });
49
50 it('should create', () => {
51 expect(component.data).toBeTruthy();
52 });
53
54 it('should prepare data', () => {
55 expect(component.data).toEqual({
56 'Access Type': 'RW',
57 'CephFS Filesystem': 1,
58 'CephFS User': 'fs',
59 Cluster: 'cluster1',
60 'NFS Protocol': ['NFSv4'],
61 Path: '/qwe',
62 Pseudo: '/qwe',
63 'Security Label': undefined,
64 Squash: 'no_root_squash',
65 'Storage Backend': 'CephFS',
66 Transport: ['TCP', 'UDP']
67 });
68 });
69
70 it('should prepare data if RGW', () => {
71 const newData = _.assignIn(component.selection, {
72 fsal: {
73 name: 'RGW',
74 user_id: 'user-id'
75 }
76 });
77 component.selection = newData;
78 component.ngOnChanges();
79 expect(component.data).toEqual({
80 'Access Type': 'RW',
81 Cluster: 'cluster1',
82 'NFS Protocol': ['NFSv4'],
83 'Object Gateway User': 'user-id',
84 Path: '/qwe',
85 Pseudo: '/qwe',
86 Squash: 'no_root_squash',
87 'Storage Backend': 'Object Gateway',
88 Transport: ['TCP', 'UDP']
89 });
90 });
91
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([
95 {
96 access_type: 'RW',
97 addresses: ['192.168.0.10', '192.168.1.0/8'],
98 squash: 'root_id_squash'
99 }
100 ]);
101 });
102 });