Merge "Fix minor issues"
[portal.git] / portal-FE-common / src / app / pages / role / role.component.spec.ts
1 /*-
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  *
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
12  *
13  *             http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
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
25  *
26  *             https://creativecommons.org/licenses/by/4.0/
27  *
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.
33  *
34  * ============LICENSE_END============================================
35  *
36  * 
37  */
38 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
39
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';
52
53 describe('RoleComponent', () => {
54   let component: RoleComponent;
55   let fixture: ComponentFixture<RoleComponent>;
56
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] } })
62     .compileComponents();
63   }));
64
65   beforeEach(() => {
66     fixture = TestBed.createComponent(RoleComponent);
67     component = fixture.componentInstance;
68     fixture.detectChanges();
69   });
70
71   it('should create', () => {
72     expect(component).toBeTruthy();
73   });
74
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);
80   });
81
82   it('openBulkUploadRolesAndFunctionsModal should return stubbed value', () => {
83     spyOn(component, 'openBulkUploadRolesAndFunctionsModal').and.callThrough();
84     component.openBulkUploadRolesAndFunctionsModal();
85     expect(component.openBulkUploadRolesAndFunctionsModal).toHaveBeenCalledWith();
86   });
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);
92   });
93
94   it('addRoleModalPopup should return stubbed value', () => {
95     spyOn(component, 'addRoleModalPopup').and.callThrough();
96     component.addRoleModalPopup();
97     expect(component.addRoleModalPopup).toHaveBeenCalledWith();
98   });
99
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);
106   });
107   it('getCentralizedApps should return stubbed value', () => {
108     spyOn(component, 'getCentralizedApps').and.callThrough();
109     component.getCentralizedApps('admin');
110     expect(component.getCentralizedApps).toHaveBeenCalledWith('admin');
111   });
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();
117   });
118   it('getRolesForSelectedCentralizedApp should return stubbed value', () => {
119     spyOn(component, 'getRolesForSelectedCentralizedApp').and.callThrough();
120     component.getRolesForSelectedCentralizedApp('Test');
121     expect(component.getRolesForSelectedCentralizedApp).toHaveBeenCalledWith('Test');
122   });
123
124   
125
126   
127
128   
129 });