2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
38 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
40 import { RoleComponent } from './role.component';
41 import { FormsModule } from '@angular/forms';
42 import { NgMaterialModule } from 'src/app/ng-material-module';
43 import { HttpClientTestingModule } from '@angular/common/http/testing';
44 import { RouterLinkDirectiveStub } from 'src/testing/router-link-directive-stub';
45 import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
46 import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
47 import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
48 import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
49 import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
50 import { BulkUploadRoleComponent } from './bulk-upload-role/bulk-upload-role.component';
51 import { AddRoleComponent } from './add-role/add-role.component';
53 describe('RoleComponent', () => {
54 let component: RoleComponent;
55 let fixture: ComponentFixture<RoleComponent>;
57 beforeEach(async(() => {
58 TestBed.configureTestingModule({
59 declarations: [ RoleComponent,RouterLinkDirectiveStub,InformationModalComponent,ConfirmationModalComponent,BulkUploadRoleComponent,AddRoleComponent ],
60 imports:[FormsModule,NgMaterialModule,HttpClientTestingModule,BrowserAnimationsModule,NgbModule.forRoot()],
61 }).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [InformationModalComponent,ConfirmationModalComponent,BulkUploadRoleComponent,AddRoleComponent] } })
66 fixture = TestBed.createComponent(RoleComponent);
67 component = fixture.componentInstance;
68 fixture.detectChanges();
71 it('should create', () => {
72 expect(component).toBeTruthy();
75 it('toggleRole should return stubbed value', () => {
76 spyOn(component, 'toggleRole').and.callThrough();
77 let element={"id":1,"active":true};
78 component.toggleRole(element);
79 expect(component.toggleRole).toHaveBeenCalledWith(element);
82 it('openBulkUploadRolesAndFunctionsModal should return stubbed value', () => {
83 spyOn(component, 'openBulkUploadRolesAndFunctionsModal').and.callThrough();
84 component.openBulkUploadRolesAndFunctionsModal();
85 expect(component.openBulkUploadRolesAndFunctionsModal).toHaveBeenCalledWith();
87 it('editRoleModalPopup should return stubbed value', () => {
88 spyOn(component, 'editRoleModalPopup').and.callThrough();
89 let element={"id":1,"active":true};
90 component.editRoleModalPopup(element);
91 expect(component.editRoleModalPopup).toHaveBeenCalledWith(element);
94 it('addRoleModalPopup should return stubbed value', () => {
95 spyOn(component, 'addRoleModalPopup').and.callThrough();
96 component.addRoleModalPopup();
97 expect(component.addRoleModalPopup).toHaveBeenCalledWith();
100 it('removeRole should return stubbed value', () => {
101 spyOn(component, 'removeRole').and.callThrough();
102 let element={"id":1,"active":true,"name":"Test_global_"};
103 component.selectedCentralizedApp = 2;
104 component.removeRole(element);
105 expect(component.removeRole).toHaveBeenCalledWith(element);
107 it('getCentralizedApps should return stubbed value', () => {
108 spyOn(component, 'getCentralizedApps').and.callThrough();
109 component.getCentralizedApps('admin');
110 expect(component.getCentralizedApps).toHaveBeenCalledWith('admin');
112 it('syncRolesFromExternalAuthSystem should return stubbed value', () => {
113 spyOn(component, 'syncRolesFromExternalAuthSystem').and.callThrough();
114 component.selectedCentralizedApp = 'Test';
115 component.syncRolesFromExternalAuthSystem();
116 expect(component.syncRolesFromExternalAuthSystem).toHaveBeenCalledWith();
118 it('getRolesForSelectedCentralizedApp should return stubbed value', () => {
119 spyOn(component, 'getRolesForSelectedCentralizedApp').and.callThrough();
120 component.getRolesForSelectedCentralizedApp('Test');
121 expect(component.getRolesForSelectedCentralizedApp).toHaveBeenCalledWith('Test');