summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk
diff options
context:
space:
mode:
authorRupinder <rupinsi1@in.ibm.com>2020-02-27 18:40:10 +0530
committerRupinder <rupinsi1@in.ibm.com>2020-02-27 18:40:15 +0530
commitf55be092d6bdc767443297f21f61e281c4033c9f (patch)
tree3e3555d3da9a4a44276d647af469545e363f7ce1 /ecomp-sdk
parent37db40a2dc6e811e919b912579fbbb2b1d8cedba (diff)
wrote test case for run-report component
Written test cases for run-report.component.spec.ts Issue-ID: PORTAL-834 Change-Id: Ibd7ce9436073679510961b6dd90936990d0386b9 Signed-off-by: Rupinder<rupinsi1@in.ibm.com>
Diffstat (limited to 'ecomp-sdk')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-report.component.spec.ts109
1 files changed, 105 insertions, 4 deletions
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 f1d53d9e..4d4fe269 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,33 +2,134 @@ 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 } from '@angular/material/table';
+import { MatTableModule, MatTableDataSource } from '@angular/material/table';
-import { RunReportComponent } from './run-report.component';
+import { RunReportComponent, PeriodicElement } from './run-report.component';
+import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, SimpleChange, SimpleChanges } from '@angular/core';
+import { MatMenuModule } from '@angular/material';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { RouterTestingModule } from '@angular/router/testing';
+import { RunService } from '../run.service';
+import { GridsterConfig, GridsterItem, GridType } from 'angular-gridster2';
-describe('RunReportFinalTableComponent', () => {
+describe('RunReportComponent', () => {
let component: RunReportComponent;
let fixture: ComponentFixture<RunReportComponent>;
+ const displayedColumnsArr1 = [];
+ const DashboardReportObj1 = [];
+ const trigger = ["a","b"];
+ let change : SimpleChanges;
+ let runService : RunService;
+ let options1 = {};
beforeEach(async(() => {
TestBed.configureTestingModule({
+ schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
declarations: [ RunReportComponent ],
imports: [
NoopAnimationsModule,
MatPaginatorModule,
MatSortModule,
MatTableModule,
- ]
+ MatMenuModule,
+ HttpClientTestingModule,
+ RouterTestingModule
+ ],
+ providers: [RunService]
}).compileComponents();
+ runService = TestBed.get(RunService);
}));
beforeEach(() => {
fixture = TestBed.createComponent(RunReportComponent);
+ runService = TestBed.get(RunService);
component = fixture.componentInstance;
+ component.DashboardReportObj = DashboardReportObj1;
+ component.displayedColumnsArr = displayedColumnsArr1;
+ component.TriggerFFArr = trigger;
+ component.options = options1;
fixture.detectChanges();
});
it('should compile', () => {
expect(component).toBeTruthy();
});
+
+ it('should test the ngOnChanges method', () => {
+ fixture.detectChanges();
+ component.reportMode !== "Regular";
+ component.initCnt > 0;
+ component.TriggerFFArr.length == 0;
+
+ component.ngOnChanges(change);
+ expect(component.showMoreVert).toEqual(false);
+ 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);
+
+ runService.getReportDataWithFormFields("for", "test").subscribe((Response) => {
+ component.reportMode !== "FormField";
+ expect(component.showMoreVert).toEqual(true);
+ expect(component.showDashboardReport).toEqual(true);
+ });
+
+ component.initialQueryString !== component.queryString;
+ component.initCounter > 0;
+ component.hitCnt !== component.runButtonHitCnt;
+ expect(component.runButtonHitCnt).toEqual(component.hitCnt);
+ expect(component.initialQueryString).toEqual(component.queryString);
+ });
+
+ it('should test initialProcess method', () => {
+ component.initialProcesses();
+ component.DashboardReportObj.length > 0;
+ expect(component.dashboard).toEqual(component.DashboardReportObj);
+ expect(component.hitCnt).toEqual(component.runButtonHitCnt);
+ expect(component.initialQueryString).toEqual(component.queryString);
+ expect(component.initCounter).toEqual(component.initCounter++);
+ });
+
+ it('should test afterViewInitialProcesses method', () => {
+ component.afterViewInitialProcesses();
+ component.DashboardReportObj.length === 0;
+ component.reportMode === "Regular";
+ component.initCnt == 0;
+
+ expect(component.showMoreVert).toEqual(false);
+ 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 showError method', () => {
+ let errmsg = "errormessage";
+ let stcktrace = "stacktrace";
+ component.showError("test");
+ expect(component.errorMessage).toEqual("test"[errmsg]);
+ expect(component.stackTrace).toEqual("test"[stcktrace]);
+ expect(component.error).toEqual(true);
+ expect(component.showSpinner).toEqual(false);
+
+ });
+
+ it('should test openOptions method', () => {
+ component.openOptions();
+ expect(component.openOptionsFlag).toEqual(component.openOptionsFlag);
+ });
+
+ it('should test applyFilter method', () => {
+ let filterValue = "test"
+ component.applyFilter(filterValue);
+ expect(component.dataSource.filter).toEqual(filterValue.trim().toLowerCase());
+ });
+
});