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