diff options
5 files changed, 177 insertions, 39 deletions
diff --git a/ecomp-sdk/epsdk-app-os/pom.xml b/ecomp-sdk/epsdk-app-os/pom.xml index 4a8eae11..7e07b3d6 100644 --- a/ecomp-sdk/epsdk-app-os/pom.xml +++ b/ecomp-sdk/epsdk-app-os/pom.xml @@ -182,6 +182,7 @@ <configuration> <arguments>run-script test</arguments> + <skip>${skiptests}</skip> </configuration> </execution> 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(); }) + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts index 7cc85b94..780b3e79 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts @@ -4,7 +4,7 @@ import { FormFieldsComponent, DialogOverviewExampleDialog } from './form-fields. import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { MatDialogModule, MatSnackBarModule } from '@angular/material'; +import { MatDialogModule, MatSnackBarModule, MatDialog } from '@angular/material'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { FormFieldsService } from './form-fields.service'; import 'rxjs/add/observable/of'; @@ -25,6 +25,7 @@ describe('FormFieldsComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ schemas:[CUSTOM_ELEMENTS_SCHEMA], + providers:[MatDialog,DialogOverviewExampleDialog], declarations: [ FormFieldsComponent, DialogOverviewExampleDialog @@ -34,7 +35,7 @@ describe('FormFieldsComponent', () => { HttpClientTestingModule, MatDialogModule, MatSnackBarModule, - BrowserAnimationsModule + BrowserAnimationsModule, ] }) TestBed.overrideModule(BrowserDynamicTestingModule,{ @@ -56,6 +57,39 @@ describe('FormFieldsComponent', () => { expect(component).toBeTruthy(); }); + it('should test moveUpward method',()=>{ + component.postDownwardObj={"indrijeet":"kumar"}; + component.reportId1="reportId1"; + component.formFieldsListObj=[{"id":123}, + {"id":321}]; + var responsePostn={"message":true}; + var postDownwardObj={"orderSeq":1}; + var finalListResponse={"orderSeq":1}; + let spy1=spyOn(_formfieldservice,'getFormFieldData').and.returnValue(Observable.of(postDownwardObj)); + let spy2=spyOn(_formfieldservice,'postFormFieldData').and.returnValue(Observable.of(responsePostn)); + let spy3=spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of(finalListResponse)); + component.moveUpward(1); + expect(spy1).toHaveBeenCalled(); + expect(spy2).toHaveBeenCalled(); + expect(spy3).toHaveBeenCalled(); + }) + + it('should test moveDownward method',()=>{ + component.postDownwardObj={"indrijeet":"kumar"}; + component.reportId1="reportId1"; + component.formFieldsListObj=[{"id":123}, + {"id":321}]; + var responsePostn={"message":true}; + var postDownwardObj={"orderSeq":1}; + var finalListResponse={"orderSeq":1}; + let spy1=spyOn(_formfieldservice,'getFormFieldData').and.returnValue(Observable.of(postDownwardObj)); + let spy2=spyOn(_formfieldservice,'postFormFieldData').and.returnValue(Observable.of(responsePostn)); + let spy3=spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of(finalListResponse)); + component.moveDownward(0); + expect(spy1).toHaveBeenCalled(); + expect(spy2).toHaveBeenCalled(); + expect(spy3).toHaveBeenCalled(); + }) it('should test verify method',()=>{ spyOn(_formfieldservice,'verifySQL').and.returnValue(Observable.of(responseDefaultSQL)) @@ -246,6 +280,18 @@ it('should test createGroup method',()=>{ component.openDialog() }) + // it('should test openDialog method',()=>{ + // var result={"Name":"name"}; + // component.Groups=null; + // const dialogRef = component.dialog.open(DialogOverviewExampleDialog, { + // width: '400px', + // height: '600px', + // data: component.formFieldsListObj + // }); + // spyOn(dialogRef,'afterClosed').and.returnValue(result); + // component.openDialog(); + // }) + it('should test createGroup method',()=>{ let spy=spyOn(component,'openDialog'); component.createGroup(); 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"}] diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.spec.ts index cd1fdaa2..aaed8a2b 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.spec.ts @@ -55,8 +55,5 @@ describe('User', () => { beforeEach(() => { component=new User(8) }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); + }); |