some test cases in definition component 46/107046/2
authorIndrijeet kumar <indriku1@in.ibm.com>
Mon, 4 May 2020 14:46:36 +0000 (20:16 +0530)
committerIndrijeet Kumar <indriku1@in.ibm.com>
Mon, 4 May 2020 15:18:25 +0000 (15:18 +0000)
some test cases in definition component

Issue-ID: PORTAL-813
Change-Id: I2547c7dbd34a451a954f245bba745481d064d35c
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/definition/definition.component.spec.ts

index 9363651..cffd529 100644 (file)
@@ -1,4 +1,5 @@
 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
 import { DefinitionComponent } from './definition.component';
 import { CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
 import { HttpClientTestingModule } from '@angular/common/http/testing';
@@ -18,7 +19,7 @@ describe('DefinitionComponent', () => {
     "reportId":123,
     "reportName":"reportName",
     "reportDescr":"reportDescr",
-    "reportType":"reportType",
+    "reportType":"Linear",
     "dbInfo":"dbInfo",
     "formHelpText":"formHelpText",
     "repDefType":"repDefType",
@@ -44,7 +45,8 @@ describe('DefinitionComponent', () => {
     "weeklyRec":true,
     "monthlyRec":true,
     "dashboardLayoutJSON":'"data"',
-    "dashboardLayoutHTML":"dashboardLayoutHTML"
+    "dashboardLayoutHTML":"dashboardLayoutHTML",
+    "displayArea":{"selected":true}
   }
 
   beforeEach(async(() => {
@@ -74,19 +76,25 @@ describe('DefinitionComponent', () => {
   });
 
   it('should test ngOnInit method',()=>{
-    var params={
-      "reportId":100
-    };
     component.IncomingReportId=-1;
     component.reportMode="Create";
-    //spyOn(activatedRoute,'params').and.returnValue(Observable.of(params));
     let spy=spyOn(_definitionService,'getDefinitionPageDetails').and.returnValue(Observable.of(response));
     component.ngOnInit();
     expect(spy).toHaveBeenCalled();
+    expect(_definitionService.getDefinitionPageDetails).toHaveBeenCalled();
     expect(component.isEdit).toBe(true);
     expect(component.showDialog).toBe(false);
   });
 
+  it('should test ngOnInit method',()=>{
+    component.IncomingReportId=1;
+    component.reportMode="Edit";
+    let spy=spyOn(_definitionService,'getDefinitionPageDetails').and.returnValue(Observable.of(response));
+    component.ngOnInit();
+    expect(spy).toHaveBeenCalled();
+    expect(_definitionService.getDefinitionPageDetails).toHaveBeenCalled();
+  });
+
   it('should test first if condition in saveDefinitionInfo method',()=>{
     component.IncomingReportId=-1;
     component.reportMode="Create";