]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import { HttpClientTestingModule } from '@angular/common/http/testing'; |
2 | import { ComponentFixture, TestBed } from '@angular/core/testing'; | |
81eedcae | 3 | import { By } from '@angular/platform-browser'; |
e306af50 | 4 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; |
11fdf7f2 | 5 | |
f67539c2 TL |
6 | import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap'; |
7 | import _ from 'lodash'; | |
11fdf7f2 | 8 | |
f67539c2 TL |
9 | import { SharedModule } from '~/app/shared/shared.module'; |
10 | import { configureTestBed } from '~/testing/unit-test-helper'; | |
11fdf7f2 TL |
11 | import { NfsDetailsComponent } from './nfs-details.component'; |
12 | ||
13 | describe('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 = { |
29 | export_id: 1, | |
30 | path: '/qwe', | |
31 | fsal: { name: 'CEPH', user_id: 'fs', fs_name: 1 }, | |
32 | cluster_id: 'cluster1', | |
e306af50 | 33 | pseudo: '/qwe', |
e306af50 TL |
34 | access_type: 'RW', |
35 | squash: 'no_root_squash', | |
a4b75251 | 36 | protocols: [4], |
e306af50 TL |
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 | } | |
a4b75251 | 44 | ] |
e306af50 | 45 | }; |
81eedcae | 46 | component.ngOnChanges(); |
11fdf7f2 TL |
47 | fixture.detectChanges(); |
48 | }); | |
49 | ||
11fdf7f2 | 50 | it('should create', () => { |
11fdf7f2 TL |
51 | expect(component.data).toBeTruthy(); |
52 | }); | |
53 | ||
54 | it('should prepare data', () => { | |
11fdf7f2 TL |
55 | expect(component.data).toEqual({ |
56 | 'Access Type': 'RW', | |
57 | 'CephFS Filesystem': 1, | |
58 | 'CephFS User': 'fs', | |
59 | Cluster: 'cluster1', | |
a4b75251 | 60 | 'NFS Protocol': ['NFSv4'], |
11fdf7f2 TL |
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', () => { | |
e306af50 | 71 | const newData = _.assignIn(component.selection, { |
11fdf7f2 TL |
72 | fsal: { |
73 | name: 'RGW', | |
a4b75251 | 74 | user_id: 'user-id' |
11fdf7f2 TL |
75 | } |
76 | }); | |
e306af50 | 77 | component.selection = newData; |
11fdf7f2 TL |
78 | component.ngOnChanges(); |
79 | expect(component.data).toEqual({ | |
80 | 'Access Type': 'RW', | |
81 | Cluster: 'cluster1', | |
a4b75251 TL |
82 | 'NFS Protocol': ['NFSv4'], |
83 | 'Object Gateway User': 'user-id', | |
11fdf7f2 TL |
84 | Path: '/qwe', |
85 | Pseudo: '/qwe', | |
86 | Squash: 'no_root_squash', | |
87 | 'Storage Backend': 'Object Gateway', | |
88 | Transport: ['TCP', 'UDP'] | |
89 | }); | |
90 | }); | |
81eedcae TL |
91 | |
92 | it('should have 1 client', () => { | |
39ae355f | 93 | expect(elem('nav.nav-tabs a:nth-of-type(2)').nativeElement.textContent).toBe('Clients (1)'); |
81eedcae TL |
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 | }); | |
11fdf7f2 | 102 | }); |