summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIndrijeet kumar <indriku1@in.ibm.com>2020-04-30 07:55:29 +0530
committerIndrijeet Kumar <indriku1@in.ibm.com>2020-04-30 03:04:54 +0000
commitfc57600b2274b418bb087f5e8e13f4ca029606be (patch)
tree7cc8b96d8b4e8569abbd2098df17ee5b60b04910
parentc7f033eec8a0a88a2ae0d200b5cc5f25fe41e70f (diff)
test cases in run-report-form-fields compo
test cases in run-report-form-fields component Issue-ID: PORTAL-813 Change-Id: I9e1d89be39c4d8583bb44117158437dcb1fe1711 Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
-rw-r--r--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.ts90
1 files changed, 79 insertions, 11 deletions
diff --git a/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 b/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 54df7d82..0e1d326d 100644
--- a/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
+++ b/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
@@ -1,40 +1,49 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {FormsModule} from '@angular/forms';
import { RunReportFormFieldsComponent } from './run-report-form-fields.component';
-import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';
+import { CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
import {MatDatepickerModule} from '@angular/material/datepicker';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { RunService } from '../run.service';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
-import { of } from 'rxjs';
+import { ActivatedRoute } from '@angular/router';
describe('RunReportFormFieldsComponent', () => {
let component: RunReportFormFieldsComponent;
let fixture: ComponentFixture<RunReportFormFieldsComponent>;
let formfield =[{"validationType":1},{},{}] ;
let runService: RunService;
+ let activatedRoute:ActivatedRoute;
let environment = [
{
baseUrl: 'just for testing'
}
];
+ var responseDefPage={
+ "reportName":"reportName",
+ "reportType":"reportType",
+ }
+
var responseFormFieldGroups={"formFieldGroupsJSON":'{"Indrijeet":"kumar"}'};
var respObj={"formFieldList":{"value1":"value1"}};
beforeEach(async(() => {
TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
- imports: [FormsModule, MatDatepickerModule, HttpClientTestingModule, RouterTestingModule],
+ imports: [
+ FormsModule,
+ MatDatepickerModule,
+ HttpClientTestingModule,
+ RouterTestingModule
+ ],
declarations: [ RunReportFormFieldsComponent ],
providers: [RunService]
})
.compileComponents();
runService = TestBed.get(RunService);
- spyOn(runService, 'getDefinitionPageDetails').and.returnValue(Observable.of(environment));
- spyOn(runService, 'refreshFormFields').and.returnValue(Observable.of(environment));
-
+ spyOn(runService, 'refreshFormFields').and.returnValue(Observable.of(environment));
}));
beforeEach(() => {
@@ -42,12 +51,76 @@ describe('RunReportFormFieldsComponent', () => {
component = fixture.componentInstance;
component.formFieldList = formfield;
fixture.detectChanges();
+ activatedRoute=TestBed.get(ActivatedRoute);
});
it('should create', () => {
expect(component).toBeTruthy();
});
+ describe('should test subscribe method in ngOnInit method',()=>{
+ it('should test first if condition inside the subscribe',()=>{
+ component.reportId="reportId";
+ component.calledWithFormFields=false;
+ var response={"errormessage":true};
+ spyOn(runService,'getDefinitionPageDetails').and.returnValue(Observable.of(responseDefPage));
+ spyOn(runService,'getReportData').and.returnValue(Observable.of(response));
+ component.ngOnInit();
+ })
+
+ it('should test first if inside first if condition inside the subscribe',()=>{
+ component.reportId="reportId";
+ component.calledWithFormFields=false;
+ var response={"errormessage":false,
+ "reportName":"reportName",
+ "formFieldList":"formFieldList"
+ }
+ spyOn(runService,'getDefinitionPageDetails').and.returnValue(Observable.of(responseDefPage));
+ spyOn(runService,'getReportData').and.returnValue(Observable.of(response));
+ component.ngOnInit();
+ })
+
+ it('should test else part line 101',()=>{
+ component.reportId="reportId";
+ component.calledWithFormFields=false;
+ var response={"errormessage":false,"reportName":"reportName","formFieldList":""}
+ spyOn(runService,'getDefinitionPageDetails').and.returnValue(Observable.of(responseDefPage));
+ spyOn(runService,'getReportData').and.returnValue(Observable.of(response));
+ component.ngOnInit();
+ })
+
+ it('should test the else part line 111',()=>{
+ component.reportId="reportId";
+ component.calledWithFormFields=true;
+ spyOn(runService,'getDefinitionPageDetails').and.returnValue(Observable.of(responseDefPage));
+ component.ngOnInit();
+ })
+
+ describe('should test the else part under subscribe in ngOnInit method',()=>{
+
+ it('should test the else part 142',()=>{
+ component.reportId="reportId";
+ var response={"errormessage":false,"formFieldList":"formFieldList"};
+ var responseDefPage={
+ "reportName":"reportName",
+ "reportType":"Dashboard",
+ "dashboardLayoutJSON":'{"data":"dat"}',
+ "formFieldList":""
+ };
+ spyOn(runService,'getDefinitionPageDetails').and.returnValue(Observable.of(responseDefPage));
+ spyOn(runService,'getReportData').and.returnValue(Observable.of(response));
+ component.ngOnInit();
+ })
+})
+
+})
+
+ it('should test ngOnInit method', () => {
+ spyOn(component, 'ngOnInit').and.callThrough();
+ component.ngOnInit();
+ expect(component.ngOnInit).toHaveBeenCalled();
+ });
+
it('should test convertDate method', () => {
component.convertDate("test");
});
@@ -120,11 +193,6 @@ describe('RunReportFormFieldsComponent', () => {
component.generateQueryString();
})
- it('should test ngOnInit method', () => {
- spyOn(component, 'ngOnInit').and.callThrough();
- component.ngOnInit();
- expect(component.ngOnInit).toHaveBeenCalled();
- });
it('should test fetchAndPopulateFormFields method', () => {
component.formFieldGroupObjList=[{"formFieldList":"formFieldList"}]