1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { RouterTestingModule } from '@angular/router/testing';
5 import { TabsModule } from 'ngx-bootstrap/tabs';
7 import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
8 import { CdTableSelection } from '../../../shared/models/cd-table-selection';
9 import { SharedModule } from '../../../shared/shared.module';
10 import { RoleDetailsComponent } from './role-details.component';
12 describe('RoleDetailsComponent', () => {
13 let component: RoleDetailsComponent;
14 let fixture: ComponentFixture<RoleDetailsComponent>;
17 imports: [SharedModule, TabsModule.forRoot(), RouterTestingModule, HttpClientTestingModule],
18 declarations: [RoleDetailsComponent],
19 providers: i18nProviders
23 fixture = TestBed.createComponent(RoleDetailsComponent);
24 component = fixture.componentInstance;
25 fixture.detectChanges();
28 it('should create', () => {
29 expect(component).toBeTruthy();
32 it('should create scopes permissions [1/2]', () => {
33 component.scopes = ['log', 'rgw'];
34 component.selection = new CdTableSelection([
36 description: 'RGW Manager',
39 rgw: ['read', 'create', 'update', 'delete']
44 expect(component.scopes_permissions.length).toBe(0);
45 component.ngOnChanges();
46 expect(component.scopes_permissions).toEqual([
47 { scope: 'log', read: false, create: false, update: false, delete: false },
48 { scope: 'rgw', read: true, create: true, update: true, delete: true }
52 it('should create scopes permissions [2/2]', () => {
53 component.scopes = ['cephfs', 'log', 'rgw'];
54 component.selection = new CdTableSelection([
59 log: ['read', 'update'],
60 rgw: ['read', 'create', 'update']
65 expect(component.scopes_permissions.length).toBe(0);
66 component.ngOnChanges();
67 expect(component.scopes_permissions).toEqual([
68 { scope: 'cephfs', read: false, create: false, update: false, delete: false },
69 { scope: 'log', read: true, create: false, update: true, delete: false },
70 { scope: 'rgw', read: true, create: true, update: true, delete: false }