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