diff options
author | Indrijeet kumar <indriku1@in.ibm.com> | 2020-03-09 16:26:40 +0530 |
---|---|---|
committer | Indrijeet kumar <indriku1@in.ibm.com> | 2020-03-09 16:26:49 +0530 |
commit | 981305cc7e578bdb4af45a2918d48a326d9f6ef8 (patch) | |
tree | 4b757aff87fe0531a455affabb234b084c2c61a9 | |
parent | c609ff2416224308262435b5d551700ef5f264d0 (diff) |
test cases written in definition component
test cases written in definition component
Issue-ID: PORTAL-813
Change-Id: Ib10a4a07c21ad431e37ab0a12d4eafad69856bc7
Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/definition.component.spec.ts | 128 |
1 files changed, 126 insertions, 2 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 e137dfd6..762d780f 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,14 +1,21 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { DefinitionComponent } from './definition.component'; -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { CUSTOM_ELEMENTS_SCHEMA, Component } 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'; describe('PilotPageComponent', () => { let component: DefinitionComponent; let fixture: ComponentFixture<DefinitionComponent>; + let _http:Http; + let _definitionService:DefinitionService; beforeEach(async(() => { TestBed.configureTestingModule({ @@ -18,7 +25,7 @@ describe('PilotPageComponent', () => { FormsModule, HttpClientTestingModule, RouterTestingModule - ] + ], }) .compileComponents(); })); @@ -27,9 +34,126 @@ describe('PilotPageComponent', () => { fixture = TestBed.createComponent(DefinitionComponent); component = fixture.componentInstance; fixture.detectChanges(); + _definitionService=TestBed.get(DefinitionService) }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('should test ngOnInit method',()=>{ + component.ngOnInit(); + 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"; + component.allowScheduler=true; + component.sizedByContent = true; + component.saveDefinitionInfo(); + expect(component.finalPostObj["tabName"]).toEqual("Definition"); + expect(component.finalPostObj["tabId"]).toEqual("Def"); + expect(component.finalPostObj["reportId"]).toEqual(component.reportId); + expect(component.finalPostObj["reportName"]).toEqual(component.reportName); + expect(component.finalPostObj["reportDescr"]).toEqual(component.reportDescription); + expect(component.finalPostObj["reportType"]).toEqual(component.reportType); + expect(component.finalPostObj["reportTypeList"]).toEqual(null); + 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); + expect(component.finalPostObj["dataGridAlign"]).toEqual(component.gridAlign); + expect(component.finalPostObj["emptyMessage"]).toEqual(component.emptyMessage); + expect(component.finalPostObj["dataContainerHeight"]).toEqual(component.heightContainer); + expect(component.finalPostObj["dataContainerWidth"]).toEqual(component.widthContainer); + expect(component.finalPostObj["runtimeColSortDisabled"]).toEqual(component.disableColumnSort); + expect(component.finalPostObj["numFormCols"]).toEqual(component.runTimeFormNum); + expect(component.finalPostObj["reportTitle"]).toEqual(component.reportTitle); + expect(component.finalPostObj["reportSubTitle"]).toEqual(component.reportSubTitle); + expect(component.finalPostObj["oneTimeRec"]).toEqual(component.oneTime); + expect(component.finalPostObj["hourlyRec"]).toEqual(component.hourly); + expect(component.finalPostObj["dailyRec"]).toEqual(component.daily); + expect(component.finalPostObj["dailyMFRec"]).toEqual(component.MonFri); + expect(component.finalPostObj["weeklyRec"]).toEqual(component.Weekly); + expect(component.finalPostObj["monthlyRec"]).toEqual(component.Monthly); + expect(component.finalPostObj["allowScheduler"]).toEqual("Y"); + expect(component.finalPostObj["sizedByContent"]).toEqual("Y"); + expect(component.finalPostObj["repDefType"]).toEqual(component.reportDefinition); + + }) + + it('should test second if condition in saveDefinitionInfo method',()=>{ + component.IncomingReportId=1; + component.reportMode="Edit"; + component.allowScheduler=true; + component.sizedByContent = true; + component.reportType="Dashboard"; + component.saveDefinitionInfo(); + + expect(component.finalPostObj["tabName"]).toEqual("Definition"); + expect(component.finalPostObj["tabId"]).toEqual("Def"); + expect(component.finalPostObj["reportId"]).toEqual(component.reportId); + expect(component.finalPostObj["reportName"]).toEqual(component.reportName); + expect(component.finalPostObj["reportDescr"]).toEqual(component.reportDescription); + expect(component.finalPostObj["reportType"]).toEqual(component.reportType); + + expect(component.finalPostObj["dashboardLayoutJSON"]).toEqual(JSON.stringify(component.dashboardObj)); + expect(component.finalPostObj["dashboardLayoutHTML"]).toEqual(component.dashboardLayoutHTML); + + }) + + + + it('should test else condition inside second if condition in saveDefinitionInfo method',()=>{ + component.IncomingReportId=1; + component.reportMode="Edit"; + component.reportType!="dashboard"; + component.saveDefinitionInfo(); + expect(component.finalPostObj["reportTypeList"]).toEqual(null); + expect(component.finalPostObj["dbInfo"]).toEqual(component.dataSrc); + expect(component.finalPostObj["formHekpText"]).toEqual(component.helpText); + expect(component.finalPostObj["pageSize"]).toEqual(component.pageSize); + }) + + it('should test subscribe in second if condition present inside saveDefinitionnInfo method',()=>{ + component.IncomingReportId=1; + component.reportMode="Edit"; + component.showDialog=true; + let spy=spyOn(_definitionService,'portDefinitionPageDetails').and.returnValue(Observable.of('')) + component.saveDefinitionInfo(); + expect(spy).toHaveBeenCalled() + expect(component.status).toEqual("Failure!"); + expect(component.message).toEqual("Definition could not be updated."); + expect(component.showDialog).toBe(false); + expect(component.closable).toBe(true); + + }) + + + + it('should test close method',()=>{ + component.showDialog=true; + component.close(); + expect(component.showDialog).toEqual(false); + expect(component.closable).toEqual(false); + }) + + it('should test onTransferDashboardObj method',()=>{ + expect(component.onTransferDashboardObj('value')).toBeUndefined(); + }) }); |