1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { NO_ERRORS_SCHEMA } from '@angular/core';
3 import { ComponentFixture, TestBed } from '@angular/core/testing';
4 import { RouterTestingModule } from '@angular/router/testing';
6 import { ModalModule } from 'ngx-bootstrap/modal';
12 } from '../../../../testing/unit-test-helper';
13 import { TableActionsComponent } from '../../../shared/datatable/table-actions/table-actions.component';
14 import { SharedModule } from '../../../shared/shared.module';
15 import { RgwUserListComponent } from './rgw-user-list.component';
17 describe('RgwUserListComponent', () => {
18 let component: RgwUserListComponent;
19 let fixture: ComponentFixture<RgwUserListComponent>;
22 declarations: [RgwUserListComponent],
23 imports: [RouterTestingModule, HttpClientTestingModule, ModalModule.forRoot(), SharedModule],
24 schemas: [NO_ERRORS_SCHEMA],
25 providers: i18nProviders
29 fixture = TestBed.createComponent(RgwUserListComponent);
30 component = fixture.componentInstance;
33 it('should create', () => {
34 fixture.detectChanges();
35 expect(component).toBeTruthy();
38 it('should test all TableActions combinations', () => {
39 const permissionHelper: PermissionHelper = new PermissionHelper(component.permission);
40 const tableActions: TableActionsComponent = permissionHelper.setPermissionsAndGetActions(
41 component.tableActions
44 expect(tableActions).toEqual({
45 'create,update,delete': {
46 actions: ['Create', 'Edit', 'Delete'],
47 primary: { multiple: 'Delete', executing: 'Edit', single: 'Edit', no: 'Create' }
50 actions: ['Create', 'Edit'],
51 primary: { multiple: 'Create', executing: 'Edit', single: 'Edit', no: 'Create' }
54 actions: ['Create', 'Delete'],
55 primary: { multiple: 'Delete', executing: 'Create', single: 'Create', no: 'Create' }
59 primary: { multiple: 'Create', executing: 'Create', single: 'Create', no: 'Create' }
62 actions: ['Edit', 'Delete'],
63 primary: { multiple: 'Delete', executing: 'Edit', single: 'Edit', no: 'Edit' }
67 primary: { multiple: 'Edit', executing: 'Edit', single: 'Edit', no: 'Edit' }
71 primary: { multiple: 'Delete', executing: 'Delete', single: 'Delete', no: 'Delete' }
75 primary: { multiple: '', executing: '', single: '', no: '' }