]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-list/rgw-user-list.component.spec.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / rgw / rgw-user-list / rgw-user-list.component.spec.ts
CommitLineData
11fdf7f2
TL
1import { HttpClientTestingModule } from '@angular/common/http/testing';
2import { NO_ERRORS_SCHEMA } from '@angular/core';
3import { ComponentFixture, TestBed } from '@angular/core/testing';
11fdf7f2
TL
4import { RouterTestingModule } from '@angular/router/testing';
5
6import { ModalModule } from 'ngx-bootstrap/modal';
7
8import {
9 configureTestBed,
10 i18nProviders,
11 PermissionHelper
12} from '../../../../testing/unit-test-helper';
11fdf7f2
TL
13import { TableActionsComponent } from '../../../shared/datatable/table-actions/table-actions.component';
14import { SharedModule } from '../../../shared/shared.module';
15import { RgwUserListComponent } from './rgw-user-list.component';
16
17describe('RgwUserListComponent', () => {
18 let component: RgwUserListComponent;
19 let fixture: ComponentFixture<RgwUserListComponent>;
20
21 configureTestBed({
22 declarations: [RgwUserListComponent],
23 imports: [RouterTestingModule, HttpClientTestingModule, ModalModule.forRoot(), SharedModule],
24 schemas: [NO_ERRORS_SCHEMA],
25 providers: i18nProviders
26 });
27
28 beforeEach(() => {
29 fixture = TestBed.createComponent(RgwUserListComponent);
30 component = fixture.componentInstance;
31 });
32
33 it('should create', () => {
34 fixture.detectChanges();
35 expect(component).toBeTruthy();
36 });
37
9f95a23c
TL
38 it('should test all TableActions combinations', () => {
39 const permissionHelper: PermissionHelper = new PermissionHelper(component.permission);
40 const tableActions: TableActionsComponent = permissionHelper.setPermissionsAndGetActions(
41 component.tableActions
42 );
43
44 expect(tableActions).toEqual({
45 'create,update,delete': {
46 actions: ['Create', 'Edit', 'Delete'],
47 primary: { multiple: 'Delete', executing: 'Edit', single: 'Edit', no: 'Create' }
48 },
49 'create,update': {
50 actions: ['Create', 'Edit'],
51 primary: { multiple: 'Create', executing: 'Edit', single: 'Edit', no: 'Create' }
52 },
53 'create,delete': {
54 actions: ['Create', 'Delete'],
55 primary: { multiple: 'Delete', executing: 'Create', single: 'Create', no: 'Create' }
56 },
57 create: {
58 actions: ['Create'],
59 primary: { multiple: 'Create', executing: 'Create', single: 'Create', no: 'Create' }
60 },
61 'update,delete': {
62 actions: ['Edit', 'Delete'],
63 primary: { multiple: 'Delete', executing: 'Edit', single: 'Edit', no: 'Edit' }
64 },
65 update: {
66 actions: ['Edit'],
67 primary: { multiple: 'Edit', executing: 'Edit', single: 'Edit', no: 'Edit' }
68 },
69 delete: {
70 actions: ['Delete'],
71 primary: { multiple: 'Delete', executing: 'Delete', single: 'Delete', no: 'Delete' }
72 },
73 'no-permissions': {
74 actions: [],
75 primary: { multiple: '', executing: '', single: '', no: '' }
76 }
11fdf7f2
TL
77 });
78 });
79});