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