]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-clients/cephfs-clients.component.spec.ts
bcc630630b7d383716cdca80dc617b7614fc8afe
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cephfs / cephfs-clients / cephfs-clients.component.spec.ts
1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3
4 import { ToastrModule } from 'ngx-toastr';
5
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';
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({
21 imports: [ToastrModule.forRoot(), SharedModule, HttpClientTestingModule],
22 declarations: [CephfsClientsComponent],
23 providers: i18nProviders
24 });
25
26 beforeEach(() => {
27 fixture = TestBed.createComponent(CephfsClientsComponent);
28 component = fixture.componentInstance;
29 component.clients = {
30 status: ViewCacheStatus.ValueOk,
31 data: [{}, {}, {}, {}]
32 };
33 });
34
35 it('should create', () => {
36 fixture.detectChanges();
37 expect(component).toBeTruthy();
38 });
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 });
81 });