]> git.proxmox.com Git - ceph.git/blobdiff - 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
index 4b5ab9a16bc9e330ea1441236f68d081410acd34..bdc0dcf250d8baab0aa59942de5a282a96eac3ea 100644 (file)
@@ -1,10 +1,16 @@
 import { HttpClientTestingModule } from '@angular/common/http/testing';
 import { ComponentFixture, TestBed } from '@angular/core/testing';
-import { RouterTestingModule } from '@angular/router/testing';
+import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
 
-import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
+import { ToastrModule } from 'ngx-toastr';
 
-import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
+import {
+  configureTestBed,
+  i18nProviders,
+  PermissionHelper
+} from '../../../../testing/unit-test-helper';
+import { TableActionsComponent } from '../../../shared/datatable/table-actions/table-actions.component';
+import { ViewCacheStatus } from '../../../shared/enum/view-cache-status.enum';
 import { SharedModule } from '../../../shared/shared.module';
 import { CephfsClientsComponent } from './cephfs-clients.component';
 
@@ -14,8 +20,8 @@ describe('CephfsClientsComponent', () => {
 
   configureTestBed({
     imports: [
-      RouterTestingModule,
-      BsDropdownModule.forRoot(),
+      BrowserAnimationsModule,
+      ToastrModule.forRoot(),
       SharedModule,
       HttpClientTestingModule
     ],
@@ -26,10 +32,56 @@ describe('CephfsClientsComponent', () => {
   beforeEach(() => {
     fixture = TestBed.createComponent(CephfsClientsComponent);
     component = fixture.componentInstance;
-    fixture.detectChanges();
+    component.clients = {
+      status: ViewCacheStatus.ValueOk,
+      data: [{}, {}, {}, {}]
+    };
   });
 
   it('should create', () => {
+    fixture.detectChanges();
     expect(component).toBeTruthy();
   });
+
+  it('should test all TableActions combinations', () => {
+    const permissionHelper: PermissionHelper = new PermissionHelper(component.permission);
+    const tableActions: TableActionsComponent = permissionHelper.setPermissionsAndGetActions(
+      component.tableActions
+    );
+
+    expect(tableActions).toEqual({
+      'create,update,delete': {
+        actions: ['Evict'],
+        primary: { multiple: 'Evict', executing: 'Evict', single: 'Evict', no: 'Evict' }
+      },
+      'create,update': {
+        actions: ['Evict'],
+        primary: { multiple: 'Evict', executing: 'Evict', single: 'Evict', no: 'Evict' }
+      },
+      'create,delete': {
+        actions: [],
+        primary: { multiple: '', executing: '', single: '', no: '' }
+      },
+      create: {
+        actions: [],
+        primary: { multiple: '', executing: '', single: '', no: '' }
+      },
+      'update,delete': {
+        actions: ['Evict'],
+        primary: { multiple: 'Evict', executing: 'Evict', single: 'Evict', no: 'Evict' }
+      },
+      update: {
+        actions: ['Evict'],
+        primary: { multiple: 'Evict', executing: 'Evict', single: 'Evict', no: 'Evict' }
+      },
+      delete: {
+        actions: [],
+        primary: { multiple: '', executing: '', single: '', no: '' }
+      },
+      'no-permissions': {
+        actions: [],
+        primary: { multiple: '', executing: '', single: '', no: '' }
+      }
+    });
+  });
 });