summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts26
-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/form-fields/form-fields.component.spec.ts50
-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
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.spec.ts13
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts66
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.spec.ts5
7 files changed, 259 insertions, 61 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts
index 08e57de2..ff5937a0 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts
@@ -1,4 +1,4 @@
-import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing';
+import { async, ComponentFixture, TestBed} from '@angular/core/testing';
import { MatTableModule } from '@angular/material/table';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatSortModule } from '@angular/material/sort';
@@ -16,15 +16,16 @@ import 'rxjs/add/observable/of';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/throw';
+import { DataTableSettings } from 'portalsdk-tag-lib';
describe('MenusComponent', () => {
let component: MenusComponent;
let fixture: ComponentFixture<MenusComponent>;
let modalService: any;
let adminService:any;
- var stubData={
- "data1":{"data":"cachedRegions"}
- }
+ var stubData={"data":
+ '{"fnMenuItems":[{"active":"active"}]}'
+ }
beforeEach(async(() => {
TestBed.configureTestingModule({
@@ -58,6 +59,22 @@ describe('MenusComponent', () => {
describe('test getMenus',()=>{
it('should test getMenus',()=>{
+ let spy=spyOn(adminService,'getFnMenuItems').and.returnValue(Observable.of(stubData));
+
+ component.getMenus();
+ expect(spy).toHaveBeenCalled();
+ expect(component.settings.columns).toEqual(component.columns);
+ expect(component.settings.isPaginationEnabled).toEqual(true);
+ expect(component.settings.paginationsSize).toEqual("5");
+ expect(component.settings.isReadOnly).toEqual(false);
+ expect(component.settings.isTableSearchEnabled ).toEqual(true);
+ expect(component.settings.applicationService).toEqual(component.menuService);
+ expect(component.showSpinner).toEqual(false);
+ })
+ })
+
+ describe('test getParentData',()=>{
+ it('should test getParentData method',()=>{
let spy=spyOn(adminService,'getParentData').and.returnValue(Observable.of('you object'))
component.getParentData();
expect(spy).toHaveBeenCalled();
@@ -77,5 +94,4 @@ describe('MenusComponent', () => {
component.getParentData();
expect(spy).toHaveBeenCalled();
})
-
});
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/form-fields/form-fields.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts
index 7cc85b94..780b3e79 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts
@@ -4,7 +4,7 @@ import { FormFieldsComponent, DialogOverviewExampleDialog } from './form-fields.
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientTestingModule } from '@angular/common/http/testing';
-import { MatDialogModule, MatSnackBarModule } from '@angular/material';
+import { MatDialogModule, MatSnackBarModule, MatDialog } from '@angular/material';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormFieldsService } from './form-fields.service';
import 'rxjs/add/observable/of';
@@ -25,6 +25,7 @@ describe('FormFieldsComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
schemas:[CUSTOM_ELEMENTS_SCHEMA],
+ providers:[MatDialog,DialogOverviewExampleDialog],
declarations: [
FormFieldsComponent,
DialogOverviewExampleDialog
@@ -34,7 +35,7 @@ describe('FormFieldsComponent', () => {
HttpClientTestingModule,
MatDialogModule,
MatSnackBarModule,
- BrowserAnimationsModule
+ BrowserAnimationsModule,
]
})
TestBed.overrideModule(BrowserDynamicTestingModule,{
@@ -56,6 +57,39 @@ describe('FormFieldsComponent', () => {
expect(component).toBeTruthy();
});
+ it('should test moveUpward method',()=>{
+ component.postDownwardObj={"indrijeet":"kumar"};
+ component.reportId1="reportId1";
+ component.formFieldsListObj=[{"id":123},
+ {"id":321}];
+ var responsePostn={"message":true};
+ var postDownwardObj={"orderSeq":1};
+ var finalListResponse={"orderSeq":1};
+ let spy1=spyOn(_formfieldservice,'getFormFieldData').and.returnValue(Observable.of(postDownwardObj));
+ let spy2=spyOn(_formfieldservice,'postFormFieldData').and.returnValue(Observable.of(responsePostn));
+ let spy3=spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of(finalListResponse));
+ component.moveUpward(1);
+ expect(spy1).toHaveBeenCalled();
+ expect(spy2).toHaveBeenCalled();
+ expect(spy3).toHaveBeenCalled();
+ })
+
+ it('should test moveDownward method',()=>{
+ component.postDownwardObj={"indrijeet":"kumar"};
+ component.reportId1="reportId1";
+ component.formFieldsListObj=[{"id":123},
+ {"id":321}];
+ var responsePostn={"message":true};
+ var postDownwardObj={"orderSeq":1};
+ var finalListResponse={"orderSeq":1};
+ let spy1=spyOn(_formfieldservice,'getFormFieldData').and.returnValue(Observable.of(postDownwardObj));
+ let spy2=spyOn(_formfieldservice,'postFormFieldData').and.returnValue(Observable.of(responsePostn));
+ let spy3=spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of(finalListResponse));
+ component.moveDownward(0);
+ expect(spy1).toHaveBeenCalled();
+ expect(spy2).toHaveBeenCalled();
+ expect(spy3).toHaveBeenCalled();
+ })
it('should test verify method',()=>{
spyOn(_formfieldservice,'verifySQL').and.returnValue(Observable.of(responseDefaultSQL))
@@ -246,6 +280,18 @@ it('should test createGroup method',()=>{
component.openDialog()
})
+ // it('should test openDialog method',()=>{
+ // var result={"Name":"name"};
+ // component.Groups=null;
+ // const dialogRef = component.dialog.open(DialogOverviewExampleDialog, {
+ // width: '400px',
+ // height: '600px',
+ // data: component.formFieldsListObj
+ // });
+ // spyOn(dialogRef,'afterClosed').and.returnValue(result);
+ // component.openDialog();
+ // })
+
it('should test createGroup method',()=>{
let spy=spyOn(component,'openDialog');
component.createGroup();
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"}]
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.spec.ts
index 417b3a18..44a7ef1f 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.spec.ts
@@ -4,11 +4,11 @@ import { SecurityComponent } from './security.component';
import { FormsModule } from '@angular/forms';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { HttpClientTestingModule } from '@angular/common/http/testing';
-import { componentRefresh } from '@angular/core/src/render3/instructions';
import { SecurityService } from './security.service';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
+
describe('SecurityComponent', () => {
let component: SecurityComponent;
let fixture: ComponentFixture<SecurityComponent>;
@@ -56,7 +56,6 @@ describe('SecurityComponent', () => {
it('should test ngOnInit method', () => {
component.reportType = "Dashboard";
component.ngOnInit();
- // expect(component.showSpinner).toEqual(true);
expect(component.stepNo).toEqual('2');
component.reportType = "test";
@@ -91,24 +90,32 @@ describe('SecurityComponent', () => {
});
it("should test addReportUser method", () => {
+ component.reportUser="ind";
+ component.reportOwnerList=[{"name":"ind"}];
spyOn(component, 'addReportUser').and.callThrough();
component.addReportUser();
expect(component.addReportUser).toHaveBeenCalled();
});
it("should test removeReportUser method", () => {
- component.removeReportUser("test");
+ component.reportOwnerList=[{"name":"reportUserName"}];
+ component.removeReportUser("reportUserName");
});
it("should test addReportRole method", () => {
+ component.reportRole="reportRole";
+ component.reportRoleList=[{"name":"reportRole"}];
component.addReportRole();
});
it("should test removeReportRole method", () => {
+ component.reportSecurityRoles=[{"id":"roleId"}];
component.removeReportRole("test");
});
it("should test saveSecurityTabData method", () => {
+ component.reportOwner="reportOwner";
+ component.reportOwnerList=[{"name":"reportOwner"}];
spyOn(component, 'saveSecurityTabData').and.callThrough();
component.saveSecurityTabData();
expect(component.saveSecurityTabData).toHaveBeenCalled();
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts
index 5178b52b..52bb01f0 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts
@@ -48,29 +48,30 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { UserService } from 'src/app/shared/services/user/user.service';
import { Observable } from 'rxjs';
-import { ActivatedRoute } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { ModalDismissReasons, NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { ProfileService } from '../profile.service';
import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
+import { ErrorModalComponent } from 'src/app/modals/error-modal/error-modal.component';
+import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
describe('SelfComponent', () => {
let component: SelfComponent;
let fixture: ComponentFixture<SelfComponent>;
let userService:UserService;
let profileService:ProfileService;
- let tableobj:any=JSON.stringify({"errormessage":"DummyError","stacktrace":"trace"});
- let data={"data":'{"profile":\'{"data":"data"}\'}'};
- //var _element={"_element":true};
var _element={"_element":{"selected":true}}
-
-
beforeEach(async(() => {
TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
- declarations: [ SelfComponent,InformationModalComponent ],
+ declarations: [
+ SelfComponent,
+ InformationModalComponent,
+ ErrorModalComponent,
+ ConfirmationModalComponent
+ ],
imports: [
ReactiveFormsModule,
FormsModule,
@@ -85,7 +86,10 @@ describe('SelfComponent', () => {
})
TestBed.overrideModule(BrowserDynamicTestingModule,{
set:{
- entryComponents:[InformationModalComponent ]
+ entryComponents:[
+ InformationModalComponent,
+ ErrorModalComponent,
+ ConfirmationModalComponent]
}
})
.compileComponents();
@@ -103,9 +107,6 @@ describe('SelfComponent', () => {
expect(component).toBeTruthy();
});
- // it('should test assignProfileDetails method',()=>{
- // component.assignProfileDetails(data);
- // })
describe('should test ngOnInit method',()=>{
it('should test subscribe',()=>{
@@ -133,9 +134,46 @@ describe('SelfComponent', () => {
expect(spy).toHaveBeenCalled();
})
- // // it('should test saveProfile method',()=>{
- // // component.saveProfile()
- // // })
+ it('should test saveProfile method first if condition',()=>{
+ component.oriProfile={"loginId":"loginId1"};
+ component.profile.loginId="loginId2";
+ component.saveProfile()
+ })
+
+ it('should test saveProfile method second if condition',()=>{
+ component.oriProfile={
+ "loginId":"loginId",
+ "loginPwd":"loginPwd1"
+ };
+ component.profile.loginId="loginId";
+ component.profile.loginPwd="loginPwd2"
+ component.saveProfile()
+ })
+
+ it('should test saveProfile method',()=>{
+ component.oriProfile={
+ "loginId":"loginId",
+ "loginPwd":"loginPwd"
+ };
+ component.profile.loginId="loginId";
+ component.profile.loginPwd="loginPwd";
+ component.stateList=[{"value":"value"}];
+ component.profile.state="value";
+ component.ociCountries=[{"value":"India"}];
+ component.profile.country="India";
+ component.ociTimeZones=[{"value":"Indian"}];
+ component.profile.timeZoneId="Indian";
+ component.postData={
+ profile: "profile",
+ selectedCountry:"selectedCountry",
+ selectedState:"selectedState",
+ selectedTimeZone:"selectedTimeZone"
+ };
+ component.profileId="profileId";
+ let spy= spyOn(profileService,'saveProfile').and.returnValue(Observable.of('your object'));
+ component.saveProfile()
+ expect(spy).toHaveBeenCalled();
+ });
it('should test toggleRoles method',()=>{
component.ociavailableRoles=[{"ociavailableRoles":"ociavailableRoles"}];
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.spec.ts
index cd1fdaa2..aaed8a2b 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.spec.ts
@@ -55,8 +55,5 @@ describe('User', () => {
beforeEach(() => {
component=new User(8)
});
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
+
});