]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/active-alert-list/active-alert-list.component.spec.ts
1b2c18aced14ff932edc914ad32c0b38d3ad32fb
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / prometheus / active-alert-list / active-alert-list.component.spec.ts
1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { RouterTestingModule } from '@angular/router/testing';
4
5 import { TabsModule } from 'ngx-bootstrap/tabs';
6 import { ToastrModule } from 'ngx-toastr';
7
8 import {
9 configureTestBed,
10 i18nProviders,
11 PermissionHelper
12 } from '../../../../../testing/unit-test-helper';
13 import { CoreModule } from '../../../../core/core.module';
14 import { TableActionsComponent } from '../../../../shared/datatable/table-actions/table-actions.component';
15 import { SharedModule } from '../../../../shared/shared.module';
16 import { CephModule } from '../../../ceph.module';
17 import { DashboardModule } from '../../../dashboard/dashboard.module';
18 import { ClusterModule } from '../../cluster.module';
19 import { ActiveAlertListComponent } from './active-alert-list.component';
20
21 describe('ActiveAlertListComponent', () => {
22 let component: ActiveAlertListComponent;
23 let fixture: ComponentFixture<ActiveAlertListComponent>;
24
25 configureTestBed({
26 imports: [
27 HttpClientTestingModule,
28 TabsModule.forRoot(),
29 RouterTestingModule,
30 ToastrModule.forRoot(),
31 SharedModule,
32 ClusterModule,
33 DashboardModule,
34 CephModule,
35 CoreModule
36 ],
37 declarations: [],
38 providers: [i18nProviders]
39 });
40
41 beforeEach(() => {
42 fixture = TestBed.createComponent(ActiveAlertListComponent);
43 component = fixture.componentInstance;
44 });
45
46 it('should create', () => {
47 fixture.detectChanges();
48 expect(component).toBeTruthy();
49 });
50
51 it('should test all TableActions combinations', () => {
52 component.ngOnInit();
53 const permissionHelper: PermissionHelper = new PermissionHelper(component.permission);
54 const tableActions: TableActionsComponent = permissionHelper.setPermissionsAndGetActions(
55 component.tableActions
56 );
57
58 expect(tableActions).toEqual({
59 'create,update,delete': {
60 actions: ['Create Silence'],
61 primary: {
62 multiple: 'Create Silence',
63 executing: 'Create Silence',
64 single: 'Create Silence',
65 no: 'Create Silence'
66 }
67 },
68 'create,update': {
69 actions: ['Create Silence'],
70 primary: {
71 multiple: 'Create Silence',
72 executing: 'Create Silence',
73 single: 'Create Silence',
74 no: 'Create Silence'
75 }
76 },
77 'create,delete': {
78 actions: ['Create Silence'],
79 primary: {
80 multiple: 'Create Silence',
81 executing: 'Create Silence',
82 single: 'Create Silence',
83 no: 'Create Silence'
84 }
85 },
86 create: {
87 actions: ['Create Silence'],
88 primary: {
89 multiple: 'Create Silence',
90 executing: 'Create Silence',
91 single: 'Create Silence',
92 no: 'Create Silence'
93 }
94 },
95 'update,delete': {
96 actions: [],
97 primary: { multiple: '', executing: '', single: '', no: '' }
98 },
99 update: { actions: [], primary: { multiple: '', executing: '', single: '', no: '' } },
100 delete: { actions: [], primary: { multiple: '', executing: '', single: '', no: '' } },
101 'no-permissions': {
102 actions: [],
103 primary: { multiple: '', executing: '', single: '', no: '' }
104 }
105 });
106 });
107 });