diff options
author | 2020-02-28 14:46:30 +0530 | |
---|---|---|
committer | 2020-02-28 14:47:21 +0530 | |
commit | 72c2f40e9220af16f23f3265f85363bda2b8f1c9 (patch) | |
tree | c5794c2ba2343dc2f65f7a742aae9ce6feac0337 /ecomp-sdk/epsdk-app-overlay/src | |
parent | 1fe7926c797ca4eb839fd323b31b7b9438501878 (diff) |
added some changes in test cases
Improved some test cases in run-dashboard-report component
Issue-ID: PORTAL-834
Change-Id: Iccc4c7a2cf8ddb468dd311192b311c3c18ab3363
Signed-off-by: Rupinder<rupinsi1@in.ibm.com>
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src')
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts | 64 |
1 files changed, 43 insertions, 21 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-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-dashboard-report/run-dashboard-report.component.spec.ts index 96dcdbaa..9e1cd459 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-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-dashboard-report/run-dashboard-report.component.spec.ts @@ -6,6 +6,12 @@ import { RouterModule } from '@angular/router'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { DashboardReportService } from './dashboard-report.service'; +import { MockBackend, MockConnection } from '@angular/http/testing'; +import { Http, BaseRequestOptions } from '@angular/http'; +import { Observable } from 'rxjs'; +import 'rxjs/add/observable/empty'; +import 'rxjs/add/observable/of'; +import { environment } from 'src/environments/environment'; describe('RunDashboardReportComponent', () => { let component: RunDashboardReportComponent; @@ -17,7 +23,13 @@ describe('RunDashboardReportComponent', () => { schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [ RunDashboardReportComponent ], imports: [MatTableModule, RouterTestingModule, HttpClientTestingModule], - providers: [DashboardReportService] + providers:[DashboardReportService, MockBackend, BaseRequestOptions, { + provide: Http, + useFactory: (backend: MockBackend, defaultOptions: BaseRequestOptions) => { + return new Http(backend, defaultOptions); + }, + deps: [MockBackend, BaseRequestOptions], + }] }) .compileComponents(); dashboardService = TestBed.get(DashboardReportService); @@ -49,10 +61,13 @@ describe('RunDashboardReportComponent', () => { expect(component.dataSource.paginator).toEqual(component.paginator); }); - it('should test ngOnChanges method', () => { - component.initialQueryString !== component.queryString; + it('should test ngOnChanges methods if condition', () => { + + component.hitCnt = 1; + component.queryString = "testing" + component.initialQueryString === "test"; component.initCounter > 0; - component.runButtonHitCounter !== component.hitCnt; + component.runButtonHitCounter === 2; component.ngOnChanges(); expect(component.initialQueryString).toEqual(component.queryString); @@ -67,26 +82,33 @@ describe('RunDashboardReportComponent', () => { }); - it('should test afterViewInitProcesses method', () => { - component.afterViewInitProcesses(); - expect(component.displayedColumnsArr).toEqual(new Array()); - 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.isReady).toEqual(false); - expect(component.NEWdisplayedColumns).toEqual(new Array()); - - dashboardService.getReportDataWithFormFields("dummy", "test").subscribe((Response) => { - expect(component.formFieldPresent).toEqual(false); - expect(component.responseFormFieldListLength).toEqual(0); - expect(component.reportName).toEqual(Response["reportName"]); - }); - }); - it('should test applyFilter method', () => { component.applyFilter("testing"); expect(component.dataSource.filter).toEqual("testing".trim().toLowerCase()); }); + + it('should test afterViewInitProcesses method', () => { + component.afterViewInitProcesses(); + expect(component.displayedColumnsArr).toEqual(new Array()); + 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.isReady).toEqual(false); + expect(component.NEWdisplayedColumns).toEqual(new Array()); + }); + + describe('Should test afterViewInitProcesses', () => { + it('should validate on afterViewInitProcesses subscribe return', () => { + let spy = spyOn(dashboardService, 'getReportDataWithFormFields') + .and.returnValue(Observable.of()); + component.afterViewInitProcesses(); + // expect(component.formFieldPresent).toEqual(false); + // expect(component.responseFormFieldListLength).toEqual(0); + expect(spy).toHaveBeenCalled(); + + }); +}); + });
\ No newline at end of file |