]>
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'; | |
11fdf7f2 TL |
4 | import { RouterTestingModule } from '@angular/router/testing'; |
5 | ||
6 | import { ModalModule } from 'ngx-bootstrap/modal'; | |
7 | ||
8 | import { | |
9 | configureTestBed, | |
10 | i18nProviders, | |
11 | PermissionHelper | |
12 | } from '../../../../testing/unit-test-helper'; | |
11fdf7f2 TL |
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'; | |
16 | ||
17 | describe('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 | }); |