diff options
author | Lorraine Welch <lb2391@att.com> | 2020-04-30 18:42:59 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-04-30 18:42:59 +0000 |
commit | 1ca25e87d4779c0a83af01a20d732790251a1f85 (patch) | |
tree | 66f9c4c46de7032fbd2379cc1d3f861920719c1c /ecomp-sdk/epsdk-app-overlay/src/main/webapp | |
parent | b5774aab8e5687412b9b3e062fe8060f4c6b1e1a (diff) | |
parent | fc57600b2274b418bb087f5e8e13f4ca029606be (diff) |
Merge "test cases in run-report-form-fields compo"
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp')
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts | 90 |
1 files changed, 79 insertions, 11 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts index 54df7d82..0e1d326d 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts @@ -1,40 +1,49 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import {FormsModule} from '@angular/forms'; import { RunReportFormFieldsComponent } from './run-report-form-fields.component'; -import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core'; +import { CUSTOM_ELEMENTS_SCHEMA} from '@angular/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { RunService } from '../run.service'; import { Observable } from 'rxjs/Observable'; import 'rxjs/add/observable/of'; -import { of } from 'rxjs'; +import { ActivatedRoute } from '@angular/router'; describe('RunReportFormFieldsComponent', () => { let component: RunReportFormFieldsComponent; let fixture: ComponentFixture<RunReportFormFieldsComponent>; let formfield =[{"validationType":1},{},{}] ; let runService: RunService; + let activatedRoute:ActivatedRoute; let environment = [ { baseUrl: 'just for testing' } ]; + var responseDefPage={ + "reportName":"reportName", + "reportType":"reportType", + } + var responseFormFieldGroups={"formFieldGroupsJSON":'{"Indrijeet":"kumar"}'}; var respObj={"formFieldList":{"value1":"value1"}}; beforeEach(async(() => { TestBed.configureTestingModule({ schemas: [CUSTOM_ELEMENTS_SCHEMA], - imports: [FormsModule, MatDatepickerModule, HttpClientTestingModule, RouterTestingModule], + imports: [ + FormsModule, + MatDatepickerModule, + HttpClientTestingModule, + RouterTestingModule + ], declarations: [ RunReportFormFieldsComponent ], providers: [RunService] }) .compileComponents(); runService = TestBed.get(RunService); - spyOn(runService, 'getDefinitionPageDetails').and.returnValue(Observable.of(environment)); - spyOn(runService, 'refreshFormFields').and.returnValue(Observable.of(environment)); - + spyOn(runService, 'refreshFormFields').and.returnValue(Observable.of(environment)); })); beforeEach(() => { @@ -42,12 +51,76 @@ describe('RunReportFormFieldsComponent', () => { component = fixture.componentInstance; component.formFieldList = formfield; fixture.detectChanges(); + activatedRoute=TestBed.get(ActivatedRoute); }); it('should create', () => { expect(component).toBeTruthy(); }); + describe('should test subscribe method in ngOnInit method',()=>{ + it('should test first if condition inside the subscribe',()=>{ + component.reportId="reportId"; + component.calledWithFormFields=false; + var response={"errormessage":true}; + spyOn(runService,'getDefinitionPageDetails').and.returnValue(Observable.of(responseDefPage)); + spyOn(runService,'getReportData').and.returnValue(Observable.of(response)); + component.ngOnInit(); + }) + + it('should test first if inside first if condition inside the subscribe',()=>{ + component.reportId="reportId"; + component.calledWithFormFields=false; + var response={"errormessage":false, + "reportName":"reportName", + "formFieldList":"formFieldList" + } + spyOn(runService,'getDefinitionPageDetails').and.returnValue(Observable.of(responseDefPage)); + spyOn(runService,'getReportData').and.returnValue(Observable.of(response)); + component.ngOnInit(); + }) + + it('should test else part line 101',()=>{ + component.reportId="reportId"; + component.calledWithFormFields=false; + var response={"errormessage":false,"reportName":"reportName","formFieldList":""} + spyOn(runService,'getDefinitionPageDetails').and.returnValue(Observable.of(responseDefPage)); + spyOn(runService,'getReportData').and.returnValue(Observable.of(response)); + component.ngOnInit(); + }) + + it('should test the else part line 111',()=>{ + component.reportId="reportId"; + component.calledWithFormFields=true; + spyOn(runService,'getDefinitionPageDetails').and.returnValue(Observable.of(responseDefPage)); + component.ngOnInit(); + }) + + describe('should test the else part under subscribe in ngOnInit method',()=>{ + + it('should test the else part 142',()=>{ + component.reportId="reportId"; + var response={"errormessage":false,"formFieldList":"formFieldList"}; + var responseDefPage={ + "reportName":"reportName", + "reportType":"Dashboard", + "dashboardLayoutJSON":'{"data":"dat"}', + "formFieldList":"" + }; + spyOn(runService,'getDefinitionPageDetails').and.returnValue(Observable.of(responseDefPage)); + spyOn(runService,'getReportData').and.returnValue(Observable.of(response)); + component.ngOnInit(); + }) +}) + +}) + + it('should test ngOnInit method', () => { + spyOn(component, 'ngOnInit').and.callThrough(); + component.ngOnInit(); + expect(component.ngOnInit).toHaveBeenCalled(); + }); + it('should test convertDate method', () => { component.convertDate("test"); }); @@ -120,11 +193,6 @@ describe('RunReportFormFieldsComponent', () => { component.generateQueryString(); }) - it('should test ngOnInit method', () => { - spyOn(component, 'ngOnInit').and.callThrough(); - component.ngOnInit(); - expect(component.ngOnInit).toHaveBeenCalled(); - }); it('should test fetchAndPopulateFormFields method', () => { component.formFieldGroupObjList=[{"formFieldList":"formFieldList"}] |