test cases in run-report component 59/106759/1
authorIndrijeet kumar <indriku1@in.ibm.com>
Tue, 28 Apr 2020 18:09:59 +0000 (23:39 +0530)
committerIndrijeet kumar <indriku1@in.ibm.com>
Tue, 28 Apr 2020 18:10:07 +0000 (23:40 +0530)
test cases in run-report component

Issue-ID: PORTAL-813
Change-Id: I32282f6da188a6892c846b8a9dc3b8730e149d27
Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
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 a41b11c..2aeac4a 100644 (file)
@@ -2,10 +2,10 @@ 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, MatTableDataSource } from '@angular/material/table';
+import { MatTableModule} from '@angular/material/table';
 
-import { RunReportComponent, PeriodicElement } from './run-report.component';
-import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, SimpleChange, SimpleChanges } from '@angular/core';
+import { RunReportComponent} from './run-report.component';
+import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, SimpleChanges } from '@angular/core';
 import { MatMenuModule } from '@angular/material';
 import { HttpClientTestingModule } from '@angular/common/http/testing';
 import { RouterTestingModule } from '@angular/router/testing';
@@ -24,13 +24,12 @@ describe('RunReportComponent', () => {
   let runService : RunService;
   let options1 = {};
   let dashboard; 
-  let dashboard2; 
   let responseformfield = 1;
   let environment = [
     {
       baseUrl: 'just a link'
     }
-  ]
+  ];
 
 
   beforeEach(async(() => {
@@ -49,13 +48,10 @@ describe('RunReportComponent', () => {
       providers: [RunService]
     }).compileComponents();
     runService = TestBed.get(RunService);
-    //spyOn(runService, 'getReportDataWithFormFields').and.returnValue(Observable.of(environment));
-    //spyOn(runService, 'getReportData').and.returnValue(Observable.of(environment));
     spyOn(runService, 'downloadReportExcel').and.returnValue(Observable.of(environment));
   }));
 
   beforeEach(() => {
-    //dashboard = {"item":{"hasContent":{"name":"rupi","id":"check#check"}}};
     fixture = TestBed.createComponent(RunReportComponent);
     runService = TestBed.get(RunService);
     component = fixture.componentInstance;
@@ -107,6 +103,7 @@ describe('RunReportComponent', () => {
       expect(component.NEWdisplayedColumns).toEqual(new Array());
   });
 
+
   it('should test showError method', () => {
        let errmsg = "errormessage";
        let stcktrace = "stacktrace";
@@ -148,40 +145,40 @@ describe('RunReportComponent', () => {
 
    it('should test the ngOnChanges first If condition', () => {   
     change = {};
+    component.queryString="queryString";
+    component.reportId1="reportId1";
+    var response={"errormessage":true}
         component.reportMode !== "Regular"
         component.initCnt = 1;
         component.TriggerFFArr.length = 0;
+        let spy=spyOn(runService,'getReportDataWithFormFields').and.returnValue(Observable.of(response));
         component.ngOnChanges(change);
-        expect(component.showMoreVert).toEqual(false);
+        expect(spy).toHaveBeenCalled();
         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);
+        
   });
 
+
    it('should test initialProcess method', () => {
       component.DashboardReportObj.length = 1;
       component.initialProcesses();
   });
 
-  // it('should test postFetchingReportDataFn method', () => {
-  //     let response: any;
-  //     component.postFetchingReportDataFn(response);
-  // })
-
-  // it('should test ngOnChanges subscribe method', ()  => {
-  //     spyOn(component, 'ngOnChanges').and.callThrough();
-  //     component.ngOnChanges(change);
-  //     expect(component.ngOnChanges).toHaveBeenCalled();
+  // it('should test postFetchingReportDataFn method',()=>{
+  //   var response={
+  //                    "reportName":"reportName",
+  //                    "reportDataColumns":[{"columnTitle":"columnTitle","colId":"colId"}],
+  //                    "reportDataRows":[{"value":"value"}]
+  //                   }
+  //   component.displayedColumnsArr=["string"]
+  //   component.postFetchingReportDataFn(response)
   // })
 
-  // it('should test postFetchingReportDataFn method', () => {
-  //   let obj: any;
-  //     component.postFetchingReportDataFn(obj);
-  // })
-  
 });