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