From 2b20eaa7ab61d575cb031d521eb1cd263cae817c Mon Sep 17 00:00:00 2001 From: Rupinder Date: Wed, 4 Mar 2020 18:56:21 +0530 Subject: added test case for run-report-form-fields Written test case for run-report-form-fields component Issue-ID: PORTAL-834 Change-Id: Iabffc838804323af0c75b92cc7fb90530ef0eddf Signed-off-by: Rupinder --- .../run-report-form-fields.component.spec.ts | 63 ++++++++++++++++++++-- 1 file changed, 58 insertions(+), 5 deletions(-) (limited to 'ecomp-sdk/epsdk-app-overlay/src') 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 d693ebc0..c922b359 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 @@ -9,6 +9,7 @@ import { RouterTestingModule } from '@angular/router/testing'; describe('RunReportFormFieldsComponent', () => { let component: RunReportFormFieldsComponent; let fixture: ComponentFixture; + let formfield =[{"validationType":1},{},{}] ; beforeEach(async(() => { TestBed.configureTestingModule({ @@ -22,6 +23,7 @@ describe('RunReportFormFieldsComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(RunReportFormFieldsComponent); component = fixture.componentInstance; + component.formFieldList = formfield; fixture.detectChanges(); }); @@ -31,15 +33,20 @@ describe('RunReportFormFieldsComponent', () => { it('should test ngOnInit method', () => { component.ngOnInit(); - expect(component.showSpinner).toEqual(true); - expect(component.navigateToRun).toEqual(false); + // expect(component.showSpinner).toEqual(true); + // expect(component.navigateToRun).toEqual(false); }); - it('should test getQueryString method', () => { - component.directCallQueryParams !== ''; + it('should test convertDate method', () => { + component.convertDate("test"); + }); + + it('should test getQueryString methods', () => { + component.directCallQueryParams = 'abc'; component.getQueryString(); expect(component.getQueryString()).toEqual(component.directCallQueryParams); - component.directCallQueryParams == ''; + + component.directCallQueryParams = ""; component.getQueryString(); expect(component.getQueryString()).toEqual(component.queryString); }); @@ -57,4 +64,50 @@ describe('RunReportFormFieldsComponent', () => { expect(component.showLabel).toEqual(component.showLabel); }); + it('should test editReport method', () => { + component.editReport("test"); + }); + + it('should test runReport method', () => { + component.iSDashboardReport = "test"; + component.formFieldList.length = 1; + component.runReport(); + + expect(component.hitCnt).toBe(component.hitCnt++); + expect(component.reportMode).toBe("FormField"); + let spy = spyOn(component, 'generateQueryString'); + component.generateQueryString(); + expect(component.generateQueryString).toHaveBeenCalled(); + expect(component.showSpinner).toBe(false); + + component.iSDashboardReport = "test"; + component.formFieldList.length = 0; + component.runReport(); + + expect(component.reportMode).toBe("Regular"); + + component.iSDashboardReport = "Dashboard"; + component.runReport(); + expect(component.showSpinner).toBe(false); + expect(component.navigateToRun).toBe(true); + + + }); + + it('should test ngDoCheck method', () =>{ + component.formFieldList != undefined; + component.oldGroupSelectValue = "test"; + component.groupSelectValue = "testing"; + component.ngDoCheck(); + + expect(component.oldGroupSelectValue).toBe(component.groupSelectValue); + }); + + it('should test fetchAndPopulateFormFields method', () => { + component.fetchAndPopulateFormFields(1, "test"); + }) + + it('should test generateQueryString method',() => { + component.generateQueryString(); + }) }); \ No newline at end of file -- cgit 1.2.3-korg