diff options
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src')
4 files changed, 191 insertions, 88 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts index b9d63853..6d0c2946 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts @@ -29,30 +29,22 @@ describe('DashboardReportGridComponent', () => { it('should test ngOnInit method', () => { component.ngOnInit(); - expect(component.showSpinner).toEqual(true); - expect(component.options.outerMargin).toEqual(true); - expect(component.options.outerMarginTop).toEqual(10); - expect(component.options.outerMarginRight).toEqual(10); - expect(component.options.outerMarginBottom).toEqual(700); - expect(component.options.outerMarginLeft).toEqual(10); - expect(component.options.scrollSensitivity).toEqual(10); - expect(component.options.scrollSpeed).toEqual(20); - expect(component.options.emptyCellDragMaxCols).toEqual(null); - expect(component.options.emptyCellDragMaxRows).toEqual(null); - expect(component.options.enableOccupiedCellDrop).toEqual(true); - expect(component.options.ignoreMarginInRow).toEqual(false); - expect(component.options.draggable.enabled).toEqual(true); - expect(component.options.resizable.enabled).toEqual(true); - expect(component.options.swap).toEqual(false); - expect(component.options.pushItems).toEqual(true); - expect(component.options.disablePushOnDrag).toEqual(false); - expect(component.options.disablePushOnResize).toEqual(false); - expect(component.options.pushResizeItems).toEqual(true); - expect(component.options.disableWindowResize).toEqual(true); - expect(component.options.disableWarnings).toEqual(false); - expect(component.options.scrollToNewItems).toEqual(true); - expect(component.options.enableEmptyCellDrop).toEqual(true); - expect(component.options.minCols).toEqual(2); - expect(component.options.minRows).toEqual(2); - }) + }); + + it('should test changedOption method', () => { + component.changedOptions(); + }); + + it('should test assignCopy method', () => { + component.assignCopy(); + }); + + it('should test filterItem method', () => { + component.filterItem(1); + }); + + it('should test addItem method', () => { + component.addItem(); + }); + });
\ No newline at end of file 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 8d9003fc..88010f96 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 @@ -7,10 +7,14 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { MatDialogModule, MatSnackBarModule } from '@angular/material'; import { CommonModule } from '@angular/common'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { FormFieldsService } from './form-fields.service'; +import 'rxjs/add/observable/of'; +import { Observable } from 'rxjs/Observable'; describe('FormFieldsComponent', () => { let component: FormFieldsComponent; let fixture: ComponentFixture<FormFieldsComponent>; + let _formfieldservice: FormFieldsService; beforeEach(async(() => { TestBed.configureTestingModule({ @@ -21,7 +25,7 @@ describe('FormFieldsComponent', () => { HttpClientTestingModule, MatDialogModule, MatSnackBarModule, - // BrowserAnimationsModule + BrowserAnimationsModule ] }) .compileComponents(); @@ -31,6 +35,7 @@ describe('FormFieldsComponent', () => { fixture = TestBed.createComponent(FormFieldsComponent); component = fixture.componentInstance; fixture.detectChanges(); + _formfieldservice=TestBed.get(FormFieldsService); }); it('should create', () => { @@ -42,28 +47,37 @@ describe('FormFieldsComponent', () => { expect(component.isFirst(2)).toBe(false); }); - it('should test isLast method', () =>{ + it('should test isLast method1 ', () =>{ component.formFieldsListObj.length = 12; expect(component.isLast(15)).toEqual(false); }); - it('should test ngDoCheck method',()=>{ + it('should test isLast method2 ', () =>{ + component.formFieldsListObj.length = 12; + expect(component.isLast(11)).toEqual(true); + }); + + it('should test ngDoCheck method for if condition',()=>{ component.sqlAsDefaultValue=true; - if(component.sqlAsDefaultValue==true){ - expect(component.showDefaultSQLOption).toBe(false); - } - else{ - expect(component.showDefaultSQLOption).toBe(true); - } + component.ngDoCheck(); + expect(component.showDefaultSQLOption).toBe(true); }); + it('should test ngDoCheck method for else condition',()=>{ + component.sqlAsDefaultValue!=true; + component.ngDoCheck(); + expect(component.showDefaultSQLOption).toBe(false); +}); + it('should test setDisplayMode method',()=>{ component.setDisplayMode("setDisplayMode"); }); it('should test edit method',()=>{ + component.fieldDefaultSQL!=null; + let spy=spyOn(_formfieldservice,'getFormFieldData').and.returnValue(Observable.of('you object')); component.edit("Id"); - + expect(spy).toHaveBeenCalled(); }) it('should test add method',()=>{ @@ -127,15 +141,15 @@ it('should test deleteFromList method',()=>{ component.deleteFromList("attrib"); }); -it('should test save method',()=>{ +it('should test save method1',()=>{ + + component.visible="YES"; + component.defaultValue=false; component.save(); expect(component.showSpinner).toBe(true); expect(component.showDialog).toBe(false); expect(component.finalPOSTObj["validationType"]).toEqual(component.validationType); - if(component.visible=="YES") expect(component.finalPOSTObj["visible"]).toBe(true); - else - expect(component.finalPOSTObj["visible"]).toBe(false); expect(component.finalPOSTObj["orderSeq"]).toEqual(component.orderSeq); expect(component.finalPOSTObj["message"]).toEqual(component.message); expect(component.finalPOSTObj["groupFormField"]).toEqual(component.groupFormField); @@ -146,13 +160,47 @@ it('should test save method',()=>{ expect(component.finalPOSTObj["errorStackTrace"]).toEqual(component.errorStackTrace); expect(component.finalPOSTObj["errorMessage"]).toEqual(component.errorMessage); expect(component.finalPOSTObj["defaultValue"]).toEqual(component.defaultValue); - if(component.defaultValue===false) - expect(component.finalPOSTObj["fieldDefaultSQL"]).toBe(null); - else - expect(component.finalPOSTObj["fieldDefalultSQL"]).toEqual(component.fieldDefaultSQL); + expect(component.finalPOSTObj["fieldDefaultSQL"]).toBe(null); expect(component.finalPOSTObj["predefinedValueList"]).toEqual(component.predefinedValueList); }); +it('should test save method for else part',()=>{ + component.visible!="YES"; + component.defaultValue!=false; + component.save(); + expect(component.finalPOSTObj["visible"]).toBe(false) + expect(component.finalPOSTObj["fieldDefalultSQL"]).toEqual(component.fieldDefaultSQL); +}) + +it('should test saveFormFieldGroups method',()=>{ + component.saveFormFieldGroups(); +}) + +it('should test openSnackBar method',()=>{ + component.openSnackBar('message','action'); +}) + +it('should test deleteGroup method',()=>{ + component.deleteGroup("string"); +}) + +it('should test deleteFormGroup method',()=>{ + component.deleteFromGroup("formgroup"); +}) + +it('should test delete method',()=>{ + component.delete("delete"); +}) + +it('should test verify method',()=>{ +component.verify("Default"); +component.verify("value"); + +}) + +// it('should test createGroup method',()=>{ +// component.openDialog() +// }) }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-report.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-report.component.spec.ts index 4d4fe269..509aa82e 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-report.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-report.component.spec.ts @@ -10,7 +10,8 @@ import { MatMenuModule } from '@angular/material'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { RunService } from '../run.service'; -import { GridsterConfig, GridsterItem, GridType } from 'angular-gridster2'; +import 'rxjs/add/observable/empty'; +import 'rxjs/add/observable/of'; describe('RunReportComponent', () => { let component: RunReportComponent; @@ -21,6 +22,9 @@ describe('RunReportComponent', () => { let change : SimpleChanges; let runService : RunService; let options1 = {}; + let dashboard; + let dashboard2; + let responseformfield = 1; beforeEach(async(() => { TestBed.configureTestingModule({ @@ -41,6 +45,7 @@ describe('RunReportComponent', () => { })); beforeEach(() => { + //dashboard = {"item":{"hasContent":{"name":"rupi","id":"check#check"}}}; fixture = TestBed.createComponent(RunReportComponent); runService = TestBed.get(RunService); component = fixture.componentInstance; @@ -48,58 +53,40 @@ describe('RunReportComponent', () => { component.displayedColumnsArr = displayedColumnsArr1; component.TriggerFFArr = trigger; component.options = options1; + component.dashboard = dashboard; + component.responseFormFieldListLength = responseformfield; fixture.detectChanges(); }); it('should compile', () => { - expect(component).toBeTruthy(); + expect(component).toBeTruthy(); }); + + it('should test the ngOnChanges second If condition', () => { + component.queryString = "test" + component.runButtonHitCnt = 1; + component.initialQueryString = "abc"; + component.initCounter = 4; + component.hitCnt = 2; + component.ngOnChanges(change); - it('should test the ngOnChanges method', () => { - fixture.detectChanges(); - component.reportMode !== "Regular"; - component.initCnt > 0; - component.TriggerFFArr.length == 0; - - component.ngOnChanges(change); - expect(component.showMoreVert).toEqual(false); - expect(component.initCnt).toEqual(1); - expect(component.showDashboardReport).toEqual(false); - expect(component.displayedRowObj).toEqual(new Array()); - expect(component.displayedColumns).toEqual(new Array()); - expect(component.formFieldList).toEqual(new Array()); - expect(component.showSpinner).toEqual(true); - expect(component.NEWdisplayedColumns).toEqual(new Array()); - expect(component.isReady).toEqual(false); - - runService.getReportDataWithFormFields("for", "test").subscribe((Response) => { - component.reportMode !== "FormField"; - expect(component.showMoreVert).toEqual(true); - expect(component.showDashboardReport).toEqual(true); - }); - - component.initialQueryString !== component.queryString; - component.initCounter > 0; - component.hitCnt !== component.runButtonHitCnt; - expect(component.runButtonHitCnt).toEqual(component.hitCnt); - expect(component.initialQueryString).toEqual(component.queryString); - }); + expect(component.runButtonHitCnt).toEqual(component.hitCnt); + expect(component.initialQueryString).toEqual("test"); + spyOn(component, 'initialProcesses'); + spyOn(component, 'afterViewInitialProcesses'); + component.initialProcesses(); + component.afterViewInitialProcesses(); - it('should test initialProcess method', () => { - component.initialProcesses(); - component.DashboardReportObj.length > 0; - expect(component.dashboard).toEqual(component.DashboardReportObj); - expect(component.hitCnt).toEqual(component.runButtonHitCnt); - expect(component.initialQueryString).toEqual(component.queryString); - expect(component.initCounter).toEqual(component.initCounter++); - }); + expect(component.initialProcesses).toHaveBeenCalled(); + expect(component.afterViewInitialProcesses).toHaveBeenCalled(); +}); it('should test afterViewInitialProcesses method', () => { + component.DashboardReportObj.length = 0; + component.reportMode = "Regular"; + component.initCnt = 0; component.afterViewInitialProcesses(); - component.DashboardReportObj.length === 0; - component.reportMode === "Regular"; - component.initCnt == 0; - + expect(component.showMoreVert).toEqual(false); expect(component.displayedColumnsArr).toEqual(new Array()); expect(component.displayedRowObj).toEqual(new Array()); @@ -118,18 +105,50 @@ describe('RunReportComponent', () => { expect(component.stackTrace).toEqual("test"[stcktrace]); expect(component.error).toEqual(true); expect(component.showSpinner).toEqual(false); - }); + it('should test linkToReport', () => { + component.linkToReport("test", "abc"); + }) + + it('should test linkToFeedback', () => { + component.linkToFeedback("test", "abc"); + }) + + it('should test linkToMail', () => { + component.linkToMail("test"); + }) + it('should test openOptions method', () => { component.openOptions(); expect(component.openOptionsFlag).toEqual(component.openOptionsFlag); }); + it('should test downloadReportExcel method', () => { + component.downloadReportExcel(); + }); + it('should test applyFilter method', () => { let filterValue = "test" component.applyFilter(filterValue); expect(component.dataSource.filter).toEqual(filterValue.trim().toLowerCase()); }); + + it('should test the ngOnChanges first If condition', () => { + change = {}; + component.reportMode !== "Regular" + component.initCnt = 1; + component.TriggerFFArr.length = 0; + component.ngOnChanges(change); + expect(component.showMoreVert).toEqual(false); + expect(component.initCnt).toEqual(1); + expect(component.showDashboardReport).toEqual(false); + expect(component.displayedRowObj).toEqual(new Array()); + expect(component.displayedColumns).toEqual(new Array()); + expect(component.formFieldList).toEqual(new Array()); + expect(component.showSpinner).toEqual(true); + expect(component.NEWdisplayedColumns).toEqual(new Array()); + expect(component.isReady).toEqual(false); + }); }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/header-tabs-component/header-tabs.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/header-tabs-component/header-tabs.component.spec.ts index da392424..d8166076 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/header-tabs-component/header-tabs.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/header-tabs-component/header-tabs.component.spec.ts @@ -4,10 +4,12 @@ import { HeaderTabsComponent } from './header-tabs.component'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; +import { CommonModule } from '@angular/common'; describe('MainComponentComponent', () => { let component: HeaderTabsComponent; let fixture: ComponentFixture<HeaderTabsComponent>; + beforeEach(async(() => { TestBed.configureTestingModule({ @@ -22,9 +24,51 @@ describe('MainComponentComponent', () => { fixture = TestBed.createComponent(HeaderTabsComponent); component = fixture.componentInstance; fixture.detectChanges(); + }); it('should create', () => { expect(component).toBeTruthy(); }); + + + it('should test if condition in ngOnInit method',()=>{ + component.reportId = "" + component.reportMode="" + component.ngOnInit(); + expect(component.finalReportId).toEqual("-1"); + expect(component.repMode).toEqual("Create"); + expect(component.reportId).toEqual("-1"); + expect(component.reportMode).toEqual("Create"); + }); + + it('should test else condition in ngOnInit method',()=>{ + component.reportId="Indrijeet"; + component.reportMode="kumar"; + component.ngOnInit(); + expect(component.finalReportId).toEqual(component.reportId); + }); + + it('should test if condition in ngAfterViewInit method',()=>{ + component.reportId = ""; + component.reportMode=""; + component.ngAfterViewInit(); + expect(component.finalReportId).toEqual("-1"); + expect(component.repMode).toEqual("Create"); + expect(component.reportId).toEqual("-1"); + expect(component.reportMode).toEqual("Create"); + }); + + it('should test else condition in ngAfterViewInit method',()=>{ + component.reportId="indrijeet"; + component.reportMode="kumar"; + component.ngAfterViewInit(); + expect(component.finalReportId).toEqual(component.reportId) + expect(component.repMode).toEqual(component.reportMode) + }); + + it('should test ngDoCheck method',()=>{ + component.ngDoCheck(); + console.log(component.tabChanged); + }) }); |