summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ecomp-sdk/epsdk-app-os/pom.xml1
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/definition.component.spec.ts70
-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
3 files changed, 128 insertions, 33 deletions
diff --git a/ecomp-sdk/epsdk-app-os/pom.xml b/ecomp-sdk/epsdk-app-os/pom.xml
index 4a8eae11..7e07b3d6 100644
--- a/ecomp-sdk/epsdk-app-os/pom.xml
+++ b/ecomp-sdk/epsdk-app-os/pom.xml
@@ -182,6 +182,7 @@
<configuration>
<arguments>run-script test</arguments>
+ <skip>${skiptests}</skip>
</configuration>
</execution>
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/definition.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/definition.component.spec.ts
index 762d780f..93636519 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/definition.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/definition.component.spec.ts
@@ -1,21 +1,51 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-
import { DefinitionComponent } from './definition.component';
-import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';
+import { CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { FormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
-import { CommonModule } from '@angular/common';
-import { Http } from '@angular/http';
import 'rxjs/add/observable/of';
import { Observable } from 'rxjs/Observable';
import { DefinitionService } from './definition.service';
+import { ActivatedRoute } from '@angular/router';
-describe('PilotPageComponent', () => {
+describe('DefinitionComponent', () => {
let component: DefinitionComponent;
let fixture: ComponentFixture<DefinitionComponent>;
- let _http:Http;
let _definitionService:DefinitionService;
+ let activatedRoute:ActivatedRoute;
+ var response={
+ "reportId":123,
+ "reportName":"reportName",
+ "reportDescr":"reportDescr",
+ "reportType":"reportType",
+ "dbInfo":"dbInfo",
+ "formHelpText":"formHelpText",
+ "repDefType":"repDefType",
+ "pageSize":20,
+ "hideFormFieldsAfterRun":true,
+ "maxRowsInExcelCSVDownload":10,
+ "frozenColumns":10,
+ "dataGridAlign":"dataGridAlign",
+ "emptyMessage":"emptyMessage",
+ "dataContainerHeight":12,
+ "dataContainerWidth":13,
+ "allowScheduler":true,
+ "sizedByContent":true,
+ "displayOptions":{"string":"string"},
+ "runtimeColSortDisabled":true,
+ "numFormCols":100,
+ "reportTitle":"reportTitle",
+ "reportSubTitle":"reportSubTitle",
+ "oneTimeRec":true,
+ "hourlyRec":true,
+ "dailyRec":true,
+ "dailyMFRec":true,
+ "weeklyRec":true,
+ "monthlyRec":true,
+ "dashboardLayoutJSON":'"data"',
+ "dashboardLayoutHTML":"dashboardLayoutHTML"
+ }
beforeEach(async(() => {
TestBed.configureTestingModule({
@@ -26,6 +56,7 @@ describe('PilotPageComponent', () => {
HttpClientTestingModule,
RouterTestingModule
],
+ providers:[DefinitionService]
})
.compileComponents();
}));
@@ -34,7 +65,8 @@ describe('PilotPageComponent', () => {
fixture = TestBed.createComponent(DefinitionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
- _definitionService=TestBed.get(DefinitionService)
+ _definitionService=TestBed.get(DefinitionService);
+ activatedRoute=TestBed.get(ActivatedRoute)
});
it('should create', () => {
@@ -42,20 +74,19 @@ describe('PilotPageComponent', () => {
});
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(component.isEdit).toBe(true);
expect(component.showDialog).toBe(false);
- expect(component.showSpinner).toBe(true);
});
- // it('should test first if condition inside ngOnInit method',()=>{
- // component.IncomingReportId =-1;
- // component.reportMode = "Create";
- // let spy=spyOn(_definitionService,'getDefinitionPageDetails').and.returnValue(Observable.of(""));
- // component.ngOnInit();
- // expect(spy).toHaveBeenCalled();
- // })
-
it('should test first if condition in saveDefinitionInfo method',()=>{
component.IncomingReportId=-1;
component.reportMode="Create";
@@ -72,8 +103,6 @@ describe('PilotPageComponent', () => {
expect(component.finalPostObj["dbInfo"]).toEqual(component.dataSrc);
expect(component.finalPostObj["formHelpText"]).toEqual(component.helpText);
expect(component.finalPostObj["pageSize"]).toEqual(component.pageSize);
-
- //expect(component.finalPostObj[""]).toEqual(component.);
expect(component.finalPostObj["hideFormFieldsAfterRun"]).toEqual(component.hideFormFields1);
expect(component.finalPostObj["maxRowsInExcelCSVDownload"]).toEqual(component.maxRows);
expect(component.finalPostObj["frozenColumns"]).toEqual(component.colsFrozen);
@@ -117,8 +146,6 @@ describe('PilotPageComponent', () => {
})
-
-
it('should test else condition inside second if condition in saveDefinitionInfo method',()=>{
component.IncomingReportId=1;
component.reportMode="Edit";
@@ -144,8 +171,6 @@ describe('PilotPageComponent', () => {
})
-
-
it('should test close method',()=>{
component.showDialog=true;
component.close();
@@ -156,4 +181,5 @@ describe('PilotPageComponent', () => {
it('should test onTransferDashboardObj method',()=>{
expect(component.onTransferDashboardObj('value')).toBeUndefined();
})
+
});
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"}]