From 220a25a2566c90bc540e7190342f73824d2ff54a Mon Sep 17 00:00:00 2001 From: mravula Date: Mon, 31 Aug 2020 12:29:32 -0400 Subject: Raptor UI Changes, user profile, folder restructure Issue-ID: PORTAL-902 Change-Id: Ib76bb3fce7efe55504b75d2fc4764bafb9f8e908 Signed-off-by: mravula --- .../run-dashboard-report.component.spec.ts | 126 +++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts') diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts new file mode 100644 index 00000000..ba2fbf34 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/report-run/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts @@ -0,0 +1,126 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { MatTableModule } from '@angular/material'; +import { RunDashboardReportComponent } from './run-dashboard-report.component'; +import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { RouterModule, Router } 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; + let fixture: ComponentFixture; + let dashboardService : DashboardReportService; + let router: Router; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + schemas: [CUSTOM_ELEMENTS_SCHEMA], + declarations: [ RunDashboardReportComponent ], + imports: [MatTableModule, RouterTestingModule, HttpClientTestingModule], + providers:[DashboardReportService, MockBackend, BaseRequestOptions, { + provide: Http, + useFactory: (backend: MockBackend, defaultOptions: BaseRequestOptions) => { + return new Http(backend, defaultOptions); + }, + deps: [MockBackend, BaseRequestOptions], + }] + }) + .compileComponents(); + dashboardService = TestBed.get(DashboardReportService); + router = TestBed.get(Router); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(RunDashboardReportComponent); + component = fixture.componentInstance; + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + it('should test ngOnInit method', () => { + component.queryString = "test"; + component.ngOnInit(); + expect(component.initialQueryString).toEqual("test"); + expect(component.initCounter).toEqual(component.initCounter++); + spyOn(component, 'initialProcesses'); + component.initialProcesses(); + expect(component.initialProcesses).toHaveBeenCalled(); + }); + + it('should test initialProcess method', () => { + component.initialProcesses(); + expect(component.dataSource.paginator).toEqual(component.paginator); + }); + + it('should test ngOnChanges methods if condition', () => { + + component.hitCnt = 1; + component.queryString = "testing" + component.initialQueryString === "test"; + component.initCounter > 0; + component.runButtonHitCounter === 2; + + component.ngOnChanges(); + expect(component.initialQueryString).toEqual(component.queryString); + expect(component.runButtonHitCounter).toEqual(component.hitCnt); + + spyOn(component, 'initialProcesses'); + spyOn(component, 'afterViewInitProcesses'); + component.initialProcesses(); + component.afterViewInitProcesses(); + expect(component.initialProcesses).toHaveBeenCalled(); + expect(component.afterViewInitProcesses).toHaveBeenCalled(); + + }); + + it('should test ngOnChanges methods else condition', () => { + + component.hitCnt = 1; + component.queryString = "testing" + component.initialQueryString === "testing"; + component.initCounter = 0; + component.runButtonHitCounter === 1; + + component.ngOnChanges(); + expect(component.runButtonHitCounter).toBe(component.hitCnt); + expect(component.initialQueryString).toBe(component.queryString); + +}); + + 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()); + }); + + it('should test linkToReport method', () => { + let reportId = "abc"; + let queryParameters = "def"; + component.linkToReport(reportId, queryParameters); + }); + + it('should test linkToMail method', () => { + let mailID = "abc"; + component.linkToMail(mailID); + }); + +}); \ No newline at end of file -- cgit 1.2.3-korg