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