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