]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import { HttpClientTestingModule } from '@angular/common/http/testing'; |
2 | import { ComponentFixture, TestBed } from '@angular/core/testing'; | |
11fdf7f2 | 3 | |
9f95a23c | 4 | import { ToastrModule } from 'ngx-toastr'; |
11fdf7f2 | 5 | |
9f95a23c TL |
6 | import { |
7 | configureTestBed, | |
8 | i18nProviders, | |
9 | PermissionHelper | |
10 | } from '../../../../testing/unit-test-helper'; | |
11 | import { TableActionsComponent } from '../../../shared/datatable/table-actions/table-actions.component'; | |
12 | import { ViewCacheStatus } from '../../../shared/enum/view-cache-status.enum'; | |
11fdf7f2 TL |
13 | import { SharedModule } from '../../../shared/shared.module'; |
14 | import { CephfsClientsComponent } from './cephfs-clients.component'; | |
15 | ||
16 | describe('CephfsClientsComponent', () => { | |
17 | let component: CephfsClientsComponent; | |
18 | let fixture: ComponentFixture<CephfsClientsComponent>; | |
19 | ||
20 | configureTestBed({ | |
9f95a23c | 21 | imports: [ToastrModule.forRoot(), SharedModule, HttpClientTestingModule], |
11fdf7f2 TL |
22 | declarations: [CephfsClientsComponent], |
23 | providers: i18nProviders | |
24 | }); | |
25 | ||
26 | beforeEach(() => { | |
27 | fixture = TestBed.createComponent(CephfsClientsComponent); | |
28 | component = fixture.componentInstance; | |
9f95a23c TL |
29 | component.clients = { |
30 | status: ViewCacheStatus.ValueOk, | |
31 | data: [{}, {}, {}, {}] | |
32 | }; | |
11fdf7f2 TL |
33 | }); |
34 | ||
35 | it('should create', () => { | |
9f95a23c | 36 | fixture.detectChanges(); |
11fdf7f2 TL |
37 | expect(component).toBeTruthy(); |
38 | }); | |
9f95a23c TL |
39 | |
40 | it('should test all TableActions combinations', () => { | |
41 | const permissionHelper: PermissionHelper = new PermissionHelper(component.permission); | |
42 | const tableActions: TableActionsComponent = permissionHelper.setPermissionsAndGetActions( | |
43 | component.tableActions | |
44 | ); | |
45 | ||
46 | expect(tableActions).toEqual({ | |
47 | 'create,update,delete': { | |
48 | actions: ['Evict'], | |
49 | primary: { multiple: 'Evict', executing: 'Evict', single: 'Evict', no: 'Evict' } | |
50 | }, | |
51 | 'create,update': { | |
52 | actions: ['Evict'], | |
53 | primary: { multiple: 'Evict', executing: 'Evict', single: 'Evict', no: 'Evict' } | |
54 | }, | |
55 | 'create,delete': { | |
56 | actions: [], | |
57 | primary: { multiple: '', executing: '', single: '', no: '' } | |
58 | }, | |
59 | create: { | |
60 | actions: [], | |
61 | primary: { multiple: '', executing: '', single: '', no: '' } | |
62 | }, | |
63 | 'update,delete': { | |
64 | actions: ['Evict'], | |
65 | primary: { multiple: 'Evict', executing: 'Evict', single: 'Evict', no: 'Evict' } | |
66 | }, | |
67 | update: { | |
68 | actions: ['Evict'], | |
69 | primary: { multiple: 'Evict', executing: 'Evict', single: 'Evict', no: 'Evict' } | |
70 | }, | |
71 | delete: { | |
72 | actions: [], | |
73 | primary: { multiple: '', executing: '', single: '', no: '' } | |
74 | }, | |
75 | 'no-permissions': { | |
76 | actions: [], | |
77 | primary: { multiple: '', executing: '', single: '', no: '' } | |
78 | } | |
79 | }); | |
80 | }); | |
11fdf7f2 | 81 | }); |