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