diff options
Diffstat (limited to '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')
-rw-r--r-- | 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 | 122 |
1 files changed, 21 insertions, 101 deletions
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 0e1d326d..640128ce 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,126 +1,52 @@ 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} from '@angular/core'; +import { CUSTOM_ELEMENTS_SCHEMA, Component } 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 { ActivatedRoute } from '@angular/router'; describe('RunReportFormFieldsComponent', () => { let component: RunReportFormFieldsComponent; let fixture: ComponentFixture<RunReportFormFieldsComponent>; let formfield =[{"validationType":1},{},{}] ; let runService: RunService; - let activatedRoute:ActivatedRoute; + let formFieldGroupObjList: {}[] = []; 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, 'refreshFormFields').and.returnValue(Observable.of(environment)); + spyOn(runService, 'getDefinitionPageDetails').and.returnValue(Observable.of(environment)); + spyOn(runService, 'refreshFormFields').and.returnValue(Observable.of(environment)); + spyOn(runService, 'getFormFieldGroupsData').and.returnValue(Observable.of(environment)); })); beforeEach(() => { fixture = TestBed.createComponent(RunReportFormFieldsComponent); component = fixture.componentInstance; - component.formFieldList = formfield; + component.formFieldList = formfield; + component.formFieldGroupObjList = formFieldGroupObjList; 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"); }); @@ -148,27 +74,23 @@ describe('RunReportFormFieldsComponent', () => { expect(component.showLabel).toEqual(component.showLabel); }); - it('should test editReport method', () => { - component.editReport("test"); - }); - - it('should test runReport method', () => { - component.iSDashboardReport = "test"; + it('should test runReport method', () => { + component.iSDashboardReport = "Dashboard"; component.formFieldList.length = 1; - component.runReport(); + component.runReport(); expect(component.hitCnt).toBe(component.hitCnt++); - expect(component.reportMode).toBe("FormField"); + expect(component.reportMode).toBe('') let spy = spyOn(component, 'generateQueryString'); component.generateQueryString(); expect(component.generateQueryString).toHaveBeenCalled(); expect(component.showSpinner).toBe(false); - component.iSDashboardReport = "test"; + component.iSDashboardReport = "Dashboard"; component.formFieldList.length = 0; - component.runReport(); + component.runReport(); - expect(component.reportMode).toBe("Regular"); + expect(component.reportMode).toBe(''); component.iSDashboardReport = "Dashboard"; component.runReport(); @@ -182,7 +104,6 @@ describe('RunReportFormFieldsComponent', () => { component.formFieldList != undefined; component.oldGroupSelectValue = "test"; component.groupSelectValue = "testing"; - // component.toggleFormFieldRenderArr.length = 1; spyOn(component, 'ngDoCheck').and.callThrough(); component.ngDoCheck(); expect(component.ngDoCheck).toHaveBeenCalled(); @@ -193,11 +114,10 @@ describe('RunReportFormFieldsComponent', () => { component.generateQueryString(); }) - - it('should test fetchAndPopulateFormFields method', () => { - component.formFieldGroupObjList=[{"formFieldList":"formFieldList"}] - spyOn(runService, 'getFormFieldGroupsData').and.returnValue(Observable.of(responseFormFieldGroups)); - component.fetchAndPopulateFormFields(respObj,"value2"); - }); + it('should test ngOnInit method', () => { + spyOn(component, 'ngOnInit').and.callThrough(); + component.ngOnInit(); + expect(component.ngOnInit).toHaveBeenCalled(); + }); });
\ No newline at end of file |