wrote test case for dashboard-report-grid comp 00/106200/1
authorRupinder <rupinsi1@in.ibm.com>
Fri, 17 Apr 2020 13:42:24 +0000 (19:12 +0530)
committerRupinder <rupinsi1@in.ibm.com>
Fri, 17 Apr 2020 13:42:32 +0000 (19:12 +0530)
Issue-ID: PORTAL-834
Change-Id: I19df9558a5688a43521bff01df0154cb4955a3fd
Signed-off-by: Rupinder<rupinsi1@in.ibm.com>
ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts

index 6d0c294..d1ed806 100644 (file)
@@ -3,10 +3,21 @@ import { FormsModule } from '@angular/forms';
 import { DashboardReportGridComponent } from './dashboard-report-grid.component';
 import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
 import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { DashboardReportService } from '../../run/run-report/run-dashboard-report/dashboard-report.service';
+import { DashboardReportGridService } from './dashboard-report-grid.service';
+import 'rxjs/add/observable/of';
+import { Observable } from 'rxjs';
+import { GridsterItem } from 'angular-gridster2';
 
 describe('DashboardReportGridComponent', () => {
   let component: DashboardReportGridComponent;
   let fixture: ComponentFixture<DashboardReportGridComponent>;
+  let service;
+  let environment = [
+    {
+      baseUrl: 'just for testing'
+    }
+  ];
 
   beforeEach(async(() => {
     TestBed.configureTestingModule({
@@ -15,11 +26,15 @@ describe('DashboardReportGridComponent', () => {
       imports: [FormsModule, HttpClientTestingModule]
     })
     .compileComponents();
+    service = TestBed.get(DashboardReportGridService);
+    spyOn(service, 'getReportList').and.returnValue(Observable.of(environment));
   })); 
 
   beforeEach(() => {
     fixture = TestBed.createComponent(DashboardReportGridComponent);
     component = fixture.componentInstance;
+    environment ["rows"] = [""];
+    component.dashboard ["hasContent"] = [""];
     fixture.detectChanges();
   });
 
@@ -28,7 +43,9 @@ describe('DashboardReportGridComponent', () => {
   });
 
   it('should test ngOnInit method', () => {
+    spyOn(component, 'ngOnInit').and.callThrough();
       component.ngOnInit();
+      expect(component.ngOnInit).toHaveBeenCalled();
   });
 
   it('should test changedOption method', () => {    
@@ -47,4 +64,10 @@ describe('DashboardReportGridComponent', () => {
       component.addItem();
   });
 
+  it('should test emptyCellClick method', () => {
+    let event: MouseEvent;
+    let item: GridsterItem;
+    component.emptyCellClick(event, item);
+  });
+
 });
\ No newline at end of file