summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/definition.component.spec.ts70
1 files changed, 48 insertions, 22 deletions
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();
})
+
});