added test case for run-report-form-fields 89/102989/1
authorRupinder <rupinsi1@in.ibm.com>
Wed, 4 Mar 2020 13:26:21 +0000 (18:56 +0530)
committerRupinder <rupinsi1@in.ibm.com>
Wed, 4 Mar 2020 13:26:33 +0000 (18:56 +0530)
Written test case for run-report-form-fields component

Issue-ID: PORTAL-834
Change-Id: Iabffc838804323af0c75b92cc7fb90530ef0eddf
Signed-off-by: Rupinder<rupinsi1@in.ibm.com>
ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts

index d693ebc..c922b35 100644 (file)
@@ -9,6 +9,7 @@ import { RouterTestingModule } from '@angular/router/testing';
 describe('RunReportFormFieldsComponent', () => {
   let component: RunReportFormFieldsComponent;
   let fixture: ComponentFixture<RunReportFormFieldsComponent>;
+  let formfield =[{"validationType":1},{},{}] ;
 
   beforeEach(async(() => {
     TestBed.configureTestingModule({
@@ -22,6 +23,7 @@ describe('RunReportFormFieldsComponent', () => {
   beforeEach(() => {
     fixture = TestBed.createComponent(RunReportFormFieldsComponent);
     component = fixture.componentInstance;
+     component.formFieldList = formfield;
     fixture.detectChanges();
   });
 
@@ -31,15 +33,20 @@ describe('RunReportFormFieldsComponent', () => {
 
   it('should test ngOnInit method', () => {
         component.ngOnInit();
-        expect(component.showSpinner).toEqual(true);
-        expect(component.navigateToRun).toEqual(false);
+        // expect(component.showSpinner).toEqual(true);
+        // expect(component.navigateToRun).toEqual(false);
   });
 
-  it('should test getQueryString method', () => {
-    component.directCallQueryParams !== '';    
+  it('should test convertDate method', () => {
+      component.convertDate("test");
+  });
+
+  it('should test getQueryString methods', () => {
+    component.directCallQueryParams = 'abc';    
     component.getQueryString();
     expect(component.getQueryString()).toEqual(component.directCallQueryParams);
-    component.directCallQueryParams == '';    
+
+    component.directCallQueryParams = "";    
     component.getQueryString();
     expect(component.getQueryString()).toEqual(component.queryString);
   });
@@ -57,4 +64,50 @@ describe('RunReportFormFieldsComponent', () => {
     expect(component.showLabel).toEqual(component.showLabel);
   });
 
+  it('should test editReport method', () => {
+        component.editReport("test");
+  });
+
+   it('should test runReport method', () => {
+      component.iSDashboardReport = "test";
+      component.formFieldList.length = 1;
+       component.runReport();
+
+      expect(component.hitCnt).toBe(component.hitCnt++);
+      expect(component.reportMode).toBe("FormField");
+      let spy = spyOn(component, 'generateQueryString');
+      component.generateQueryString();
+      expect(component.generateQueryString).toHaveBeenCalled();
+      expect(component.showSpinner).toBe(false);
+
+      component.iSDashboardReport = "test";
+      component.formFieldList.length = 0;
+       component.runReport();
+
+       expect(component.reportMode).toBe("Regular");
+
+       component.iSDashboardReport = "Dashboard";
+       component.runReport();
+       expect(component.showSpinner).toBe(false);
+       expect(component.navigateToRun).toBe(true);
+
+
+   });
+
+   it('should test ngDoCheck method', () =>{
+        component.formFieldList != undefined;
+        component.oldGroupSelectValue = "test";
+        component.groupSelectValue = "testing";
+        component.ngDoCheck();
+
+        expect(component.oldGroupSelectValue).toBe(component.groupSelectValue);
+   });
+
+   it('should test fetchAndPopulateFormFields method', () => {
+        component.fetchAndPopulateFormFields(1, "test");
+   })
+
+   it('should test generateQueryString method',() => {
+      component.generateQueryString();
+   })
 });
\ No newline at end of file