diff options
author | Lorraine Welch <lb2391@att.com> | 2020-04-30 18:45:10 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-04-30 18:45:10 +0000 |
commit | 54195198923b8dda3940722df21752c7bcbf73a6 (patch) | |
tree | 28a7f524efbd6d722f7102fd5d4dc2807df112ba /ecomp-sdk/epsdk-app-overlay/src/main/webapp | |
parent | 1ca25e87d4779c0a83af01a20d732790251a1f85 (diff) | |
parent | 7c9fd6943b7adef771447b7301cd554d6b998c32 (diff) |
Merge "some test cases in definition component"
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/definition/definition.component.spec.ts | 70 |
1 files changed, 48 insertions, 22 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/definition.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/definition.component.spec.ts index 762d780f..93636519 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/definition.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/definition.component.spec.ts @@ -1,21 +1,51 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - import { DefinitionComponent } from './definition.component'; -import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core'; +import { CUSTOM_ELEMENTS_SCHEMA} from '@angular/core'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { FormsModule } from '@angular/forms'; import { RouterTestingModule } from '@angular/router/testing'; -import { CommonModule } from '@angular/common'; -import { Http } from '@angular/http'; import 'rxjs/add/observable/of'; import { Observable } from 'rxjs/Observable'; import { DefinitionService } from './definition.service'; +import { ActivatedRoute } from '@angular/router'; -describe('PilotPageComponent', () => { +describe('DefinitionComponent', () => { let component: DefinitionComponent; let fixture: ComponentFixture<DefinitionComponent>; - let _http:Http; let _definitionService:DefinitionService; + let activatedRoute:ActivatedRoute; + var response={ + "reportId":123, + "reportName":"reportName", + "reportDescr":"reportDescr", + "reportType":"reportType", + "dbInfo":"dbInfo", + "formHelpText":"formHelpText", + "repDefType":"repDefType", + "pageSize":20, + "hideFormFieldsAfterRun":true, + "maxRowsInExcelCSVDownload":10, + "frozenColumns":10, + "dataGridAlign":"dataGridAlign", + "emptyMessage":"emptyMessage", + "dataContainerHeight":12, + "dataContainerWidth":13, + "allowScheduler":true, + "sizedByContent":true, + "displayOptions":{"string":"string"}, + "runtimeColSortDisabled":true, + "numFormCols":100, + "reportTitle":"reportTitle", + "reportSubTitle":"reportSubTitle", + "oneTimeRec":true, + "hourlyRec":true, + "dailyRec":true, + "dailyMFRec":true, + "weeklyRec":true, + "monthlyRec":true, + "dashboardLayoutJSON":'"data"', + "dashboardLayoutHTML":"dashboardLayoutHTML" + } beforeEach(async(() => { TestBed.configureTestingModule({ @@ -26,6 +56,7 @@ describe('PilotPageComponent', () => { HttpClientTestingModule, RouterTestingModule ], + providers:[DefinitionService] }) .compileComponents(); })); @@ -34,7 +65,8 @@ describe('PilotPageComponent', () => { fixture = TestBed.createComponent(DefinitionComponent); component = fixture.componentInstance; fixture.detectChanges(); - _definitionService=TestBed.get(DefinitionService) + _definitionService=TestBed.get(DefinitionService); + activatedRoute=TestBed.get(ActivatedRoute) }); it('should create', () => { @@ -42,20 +74,19 @@ describe('PilotPageComponent', () => { }); it('should test ngOnInit method',()=>{ + var params={ + "reportId":100 + }; + component.IncomingReportId=-1; + component.reportMode="Create"; + //spyOn(activatedRoute,'params').and.returnValue(Observable.of(params)); + let spy=spyOn(_definitionService,'getDefinitionPageDetails').and.returnValue(Observable.of(response)); component.ngOnInit(); + expect(spy).toHaveBeenCalled(); expect(component.isEdit).toBe(true); expect(component.showDialog).toBe(false); - expect(component.showSpinner).toBe(true); }); - // it('should test first if condition inside ngOnInit method',()=>{ - // component.IncomingReportId =-1; - // component.reportMode = "Create"; - // let spy=spyOn(_definitionService,'getDefinitionPageDetails').and.returnValue(Observable.of("")); - // component.ngOnInit(); - // expect(spy).toHaveBeenCalled(); - // }) - it('should test first if condition in saveDefinitionInfo method',()=>{ component.IncomingReportId=-1; component.reportMode="Create"; @@ -72,8 +103,6 @@ describe('PilotPageComponent', () => { expect(component.finalPostObj["dbInfo"]).toEqual(component.dataSrc); expect(component.finalPostObj["formHelpText"]).toEqual(component.helpText); expect(component.finalPostObj["pageSize"]).toEqual(component.pageSize); - - //expect(component.finalPostObj[""]).toEqual(component.); expect(component.finalPostObj["hideFormFieldsAfterRun"]).toEqual(component.hideFormFields1); expect(component.finalPostObj["maxRowsInExcelCSVDownload"]).toEqual(component.maxRows); expect(component.finalPostObj["frozenColumns"]).toEqual(component.colsFrozen); @@ -117,8 +146,6 @@ describe('PilotPageComponent', () => { }) - - it('should test else condition inside second if condition in saveDefinitionInfo method',()=>{ component.IncomingReportId=1; component.reportMode="Edit"; @@ -144,8 +171,6 @@ describe('PilotPageComponent', () => { }) - - it('should test close method',()=>{ component.showDialog=true; component.close(); @@ -156,4 +181,5 @@ describe('PilotPageComponent', () => { it('should test onTransferDashboardObj method',()=>{ expect(component.onTransferDashboardObj('value')).toBeUndefined(); }) + }); |