From a67f13f058496cdc1d4afe02a3c041b093e0d4c9 Mon Sep 17 00:00:00 2001 From: Indrijeet kumar Date: Tue, 28 Apr 2020 23:39:59 +0530 Subject: test cases in run-report component test cases in run-report component Issue-ID: PORTAL-813 Change-Id: I32282f6da188a6892c846b8a9dc3b8730e149d27 Signed-off-by: Indrijeet Kumar --- .../run/run-report/run-report.component.spec.ts | 45 ++++++++++------------ 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'ecomp-sdk') 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 a41b11cd..2aeac4a2 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 @@ -2,10 +2,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { MatPaginatorModule } from '@angular/material/paginator'; import { MatSortModule } from '@angular/material/sort'; -import { MatTableModule, MatTableDataSource } from '@angular/material/table'; +import { MatTableModule} from '@angular/material/table'; -import { RunReportComponent, PeriodicElement } from './run-report.component'; -import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, SimpleChange, SimpleChanges } from '@angular/core'; +import { RunReportComponent} from './run-report.component'; +import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, SimpleChanges } from '@angular/core'; import { MatMenuModule } from '@angular/material'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; @@ -24,13 +24,12 @@ describe('RunReportComponent', () => { let runService : RunService; let options1 = {}; let dashboard; - let dashboard2; let responseformfield = 1; let environment = [ { baseUrl: 'just a link' } - ] + ]; beforeEach(async(() => { @@ -49,13 +48,10 @@ describe('RunReportComponent', () => { providers: [RunService] }).compileComponents(); runService = TestBed.get(RunService); - //spyOn(runService, 'getReportDataWithFormFields').and.returnValue(Observable.of(environment)); - //spyOn(runService, 'getReportData').and.returnValue(Observable.of(environment)); spyOn(runService, 'downloadReportExcel').and.returnValue(Observable.of(environment)); })); beforeEach(() => { - //dashboard = {"item":{"hasContent":{"name":"rupi","id":"check#check"}}}; fixture = TestBed.createComponent(RunReportComponent); runService = TestBed.get(RunService); component = fixture.componentInstance; @@ -107,6 +103,7 @@ describe('RunReportComponent', () => { expect(component.NEWdisplayedColumns).toEqual(new Array()); }); + it('should test showError method', () => { let errmsg = "errormessage"; let stcktrace = "stacktrace"; @@ -148,40 +145,40 @@ describe('RunReportComponent', () => { it('should test the ngOnChanges first If condition', () => { change = {}; + component.queryString="queryString"; + component.reportId1="reportId1"; + var response={"errormessage":true} component.reportMode !== "Regular" component.initCnt = 1; component.TriggerFFArr.length = 0; + let spy=spyOn(runService,'getReportDataWithFormFields').and.returnValue(Observable.of(response)); component.ngOnChanges(change); - expect(component.showMoreVert).toEqual(false); + expect(spy).toHaveBeenCalled(); 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); + }); + it('should test initialProcess method', () => { component.DashboardReportObj.length = 1; component.initialProcesses(); }); - // it('should test postFetchingReportDataFn method', () => { - // let response: any; - // component.postFetchingReportDataFn(response); - // }) - - // it('should test ngOnChanges subscribe method', () => { - // spyOn(component, 'ngOnChanges').and.callThrough(); - // component.ngOnChanges(change); - // expect(component.ngOnChanges).toHaveBeenCalled(); + // it('should test postFetchingReportDataFn method',()=>{ + // var response={ + // "reportName":"reportName", + // "reportDataColumns":[{"columnTitle":"columnTitle","colId":"colId"}], + // "reportDataRows":[{"value":"value"}] + // } + // component.displayedColumnsArr=["string"] + // component.postFetchingReportDataFn(response) // }) - // it('should test postFetchingReportDataFn method', () => { - // let obj: any; - // component.postFetchingReportDataFn(obj); - // }) - + }); -- cgit 1.2.3-korg