Fixed the test cases,added sonar config
[portal.git] / portal-FE-common / src / app / pages / role / bulk-upload-role / bulk-upload-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 { BulkUploadRoleComponent } from './bulk-upload-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 { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
45
46 describe('BulkUploadRoleComponent', () => {
47   let component: BulkUploadRoleComponent;
48   let fixture: ComponentFixture<BulkUploadRoleComponent>;
49
50   beforeEach(async(() => {
51     TestBed.configureTestingModule({
52       declarations: [ BulkUploadRoleComponent ],
53       imports:[FormsModule,NgMaterialModule,HttpClientTestingModule],
54       providers:[NgbActiveModal]
55     })
56     .compileComponents();
57   }));
58
59   beforeEach(() => {
60     fixture = TestBed.createComponent(BulkUploadRoleComponent);
61     component = fixture.componentInstance;
62     fixture.detectChanges();
63   });
64
65   it('should create', () => {
66     expect(component).toBeTruthy();
67   });
68
69   it('changeUploadTypeInstruction should return stubbed value', () => {
70     spyOn(component, 'changeUploadTypeInstruction').and.callThrough();
71     component.changeUploadTypeInstruction("functions");
72     expect(component.changeUploadTypeInstruction).toHaveBeenCalledWith("functions");
73     component.changeUploadTypeInstruction("roles");
74     expect(component.changeUploadTypeInstruction).toHaveBeenCalledWith("roles");
75     component.changeUploadTypeInstruction("roleFunctions");
76     expect(component.changeUploadTypeInstruction).toHaveBeenCalledWith("roleFunctions"); 
77     component.changeUploadTypeInstruction("default");
78     expect(component.changeUploadTypeInstruction).toHaveBeenCalledWith("default") ;
79   });
80
81   it('navigateUploadScreen should return stubbed value', () => {
82     spyOn(component, 'navigateUploadScreen').and.callThrough();
83     component.selectedUploadDropdown.value='functions';
84     component.navigateUploadScreen();
85     expect(component.navigateUploadScreen).toHaveBeenCalledWith();
86     component.selectedUploadDropdown.value='roles';
87     component.navigateUploadScreen();
88     expect(component.navigateUploadScreen).toHaveBeenCalledWith();
89     component.selectedUploadDropdown.value='roleFunctions';
90     component.navigateUploadScreen();
91     expect(component.navigateUploadScreen).toHaveBeenCalledWith();
92     component.selectedUploadDropdown.value='default';
93     component.navigateUploadScreen();
94     expect(component.navigateUploadScreen).toHaveBeenCalledWith();
95   });
96   it('navigateSelectTypeUpload should return stubbed value', () => {
97     spyOn(component, 'navigateSelectTypeUpload').and.callThrough();
98     component.navigateSelectTypeUpload();
99     expect(component.navigateSelectTypeUpload).toHaveBeenCalledWith();
100   });
101   
102   it('getSortOrder should return stubbed value', () => {
103     spyOn(component, 'getSortOrder').and.callThrough();
104     component.getSortOrder(1,true);
105     expect(component.getSortOrder).toHaveBeenCalledWith(1,true);
106   });
107 });