diff options
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app')
11 files changed, 340 insertions, 59 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.ts index 1b22cf28..9df51b51 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.ts @@ -42,12 +42,23 @@ import { HttpClient } from '@angular/common/http'; import { RdpCrudInterface } from 'portalsdk-tag-lib'; import { environment } from 'src/environments/environment'; import { AdminService } from '../admin.service'; +import { BehaviorSubject } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class MenusService implements RdpCrudInterface { + public statusResponse = new BehaviorSubject(""); + public updatedData = new BehaviorSubject<any>({}); + + loadTableData(filter: any, sortActive: any, sortDirection: any, pageIndex: any, pageSize: any): import("rxjs").Observable<any[]> { + throw new Error("Method not implemented."); + } + getTotalRowCount() { + throw new Error("Method not implemented."); + } + parentDataList: any; constructor(private http: HttpClient, private adminService: AdminService) { @@ -108,6 +119,7 @@ export class MenusService implements RdpCrudInterface { this.adminService.updateFnMenuItem(postData) .subscribe(_data => { console.log("Response : ", _data); + this.statusResponse.next("200"); }, error => { console.log("Error : ", error); }); @@ -122,6 +134,9 @@ export class MenusService implements RdpCrudInterface { let result = { availableFnMenuItem: data }; this.adminService.deleteMenu(result).subscribe(response => { console.log("Response ", response); + this.statusResponse.next("200"); + }, error =>{ + console.log("Error : ", error); }) } @@ -133,7 +148,15 @@ export class MenusService implements RdpCrudInterface { } } - get(data: any) { - console.log("get method is getting called from AppServie data:: ", data); + get() { + console.log("get method is getting called from AppServie data:: "); + let response = this.adminService.getFnMenuItems(); + let resp; + response.subscribe(res => { + console.log("Get Response : ", res); + resp = res; + console.log("edited : ",JSON.parse(resp.data).fnMenuItems); + this.updatedData.next(JSON.parse(resp.data).fnMenuItems); + }) } } diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.service.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.service.ts index 9d931d1d..b0595361 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.service.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.service.ts @@ -1,34 +1,57 @@ import { Injectable } from '@angular/core'; import { RdpCrudInterface } from 'portalsdk-tag-lib'; import { AdminService } from '../admin.service'; +import { BehaviorSubject } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class RoleFunctionsService implements RdpCrudInterface { + public statusResponse = new BehaviorSubject(""); + public updatedData = new BehaviorSubject<any>({}); + + loadTableData(filter: any, sortActive: any, sortDirection: any, pageIndex: any, pageSize: any): import("rxjs").Observable<any[]> { + throw new Error("Method not implemented."); + } + getTotalRowCount() { + throw new Error("Method not implemented."); + } + constructor(private adminService: AdminService) { } add(data: any) { - console.log("Add method is getting called from AppServie data:: ", data); + console.log("Add method is getting called from RoleFunctionService data:: ", data); } - update(data: any) { - console.log("Update method is getting called from MenusService data:: ", data); - this.adminService.saveRoleFunction(data).subscribe(response => { - console.log(response); + update(data: any): any { + console.log("Update method is getting called from RoleFunctionService data:: ", data); + return this.adminService.saveRoleFunction(data).subscribe(response => { + console.log("Success Response ", response); + this.statusResponse.next("200"); + }, error => { + console.log("Error ", error); }) } delete(data: any) { - console.log("Delete method is getting called from AppServie data::>> " + JSON.stringify(data)); + console.log("Delete method is getting called from RoleFunctionService data::>> " + JSON.stringify(data)); this.adminService.deleteRoleFunction(data).subscribe(response => { - console.log("Repsonse : ",response); + console.log("Repsonse : ", response); + this.statusResponse.next("200"); + }) } - get(data: any) { - console.log("get method is getting called from AppServie data:: ", data); + get() { + let response = this.adminService.getRoleFunctionList(); + let editedData; + response.subscribe(res => { + editedData = res; + let data = JSON.parse(JSON.parse(editedData.data).availableRoleFunctions); + console.log("Get Method called : ", data); + this.updatedData.next(data); + }) } } 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 42544a72..1dab68ba 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 @@ -1,6 +1,11 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { FormFieldsComponent } from './form-fields.component'; +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 { CommonModule } from '@angular/common'; describe('FormFieldsComponent', () => { let component: FormFieldsComponent; @@ -8,7 +13,9 @@ describe('FormFieldsComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ FormFieldsComponent ] + schemas:[CUSTOM_ELEMENTS_SCHEMA], + declarations: [ FormFieldsComponent ], + imports:[FormsModule,HttpClientTestingModule,MatDialogModule,MatSnackBarModule] }) .compileComponents(); })); @@ -22,4 +29,25 @@ describe('FormFieldsComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('should test isFirst method',()=>{ + expect(component.isFirst(0)).toBe(true); + expect(component.isFirst(2)).toBe(false); + }); + + it('should test isLast method', () =>{ + component.formFieldsListObj.length = 12; + expect(component.isLast(15)).toEqual(false); + }); + + it('should test ngDoCheck method',()=>{ + component.sqlAsDefaultValue=true; + if(component.sqlAsDefaultValue==true){ + expect(component.showDefaultSQLOption).toBe(false); + } + else{ + expect(component.showDefaultSQLOption).toBe(true); + } + }); + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.service.spec.ts index d7b3b648..872a5de4 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.service.spec.ts @@ -2,15 +2,32 @@ import { TestBed } from '@angular/core/testing'; import { LogService } from './log.service'; import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { HttpClient } from '@angular/common/http'; +import { environment } from 'src/environments/environment'; describe('LogService', () => { + + let service: LogService + beforeEach(() => + { TestBed.configureTestingModule({ - imports: [HttpClientTestingModule] - })); + imports: [HttpClientTestingModule], + providers: [LogService, HttpClient, HttpClientTestingModule] + }) + service = TestBed.get(LogService); + +}); it('should be created', () => { const service: LogService = TestBed.get(LogService); expect(service).toBeTruthy(); }); + + it('should getLogData', () => { + service.getLogData("test").subscribe((res) => { + expect(res).toBe(environment.baseUrl); + }); + }); + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run.service.spec.ts index b50fc923..45bf2433 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run.service.spec.ts @@ -2,15 +2,60 @@ import { TestBed } from '@angular/core/testing'; import { RunService } from './run.service'; import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { HttpClient } from '@angular/common/http'; +import { environment } from 'src/environments/environment'; describe('RunService', () => { + let service: RunService; + beforeEach(() => + { TestBed.configureTestingModule({ - imports: [HttpClientTestingModule] - })); + imports: [HttpClientTestingModule], + providers: [HttpClient, HttpClientTestingModule, RunService] + }); + + service = TestBed.get(RunService); +}); it('should be created', () => { const service: RunService = TestBed.get(RunService); expect(service).toBeTruthy(); }); + + it('should getReportData', () => { + service.getReportData("test").subscribe((res) => { + expect(res).toBe(environment); + }); + }); + + it('should getReportDataWithFormFields', () => { + service.getReportDataWithFormFields("just", "testing").subscribe((res) => { + expect(res).toBe(environment); + }); + }); + + it('should getDefinitionPageDetails', () => { + service.getDefinitionPageDetails(1).subscribe((res) => { + expect(res).toBe(environment); + }); + }); + + it('should refreshFormFields', () => { + service.refreshFormFields("just", "testing").subscribe((res) => { + expect(res).toBe(environment); + }); + }); + + it('should getFormFieldGroupsData', () => { + service.getFormFieldGroupsData("test").subscribe((res) => { + expect(res).toBe(environment); + }); + }); + + it('should downloadReportExcel', () => { + service.downloadReportExcel("test").subscribe((res) => { + expect(res).toBe(new Blob); + }); + }); }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.service.spec.ts index 3c495ce1..f339dcac 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.service.spec.ts @@ -1,12 +1,104 @@ import { TestBed } from '@angular/core/testing'; import { SecurityService } from './security.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { environment } from 'src/environments/environment'; +import { HttpClient } from '@angular/common/http'; describe('SecurityService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + let service: SecurityService; + + beforeEach(() =>{ TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + providers: [SecurityService, HttpClientTestingModule, HttpClient] + }) + service = TestBed.get(SecurityService); +}); it('should be created', () => { const service: SecurityService = TestBed.get(SecurityService); expect(service).toBeTruthy(); }); + + it('should get reportOwnerList', () => { + service.getReportOwnerList().subscribe((resp) => { + expect(resp).toBe(environment.baseUrl + "report/wizard/security/retrieveReportOwner"); + }); + }); + + it('should get getReportRoleList', () => { + service.getReportRoleList().subscribe((resp) => { + expect(resp).toBe(environment.baseUrl + "report/wizard/security/retrieveReportRoleList"); + }); +}); + +it('should get getReportSecurityInfo', () => { + service.getReportSecurityInfo().subscribe((resp) => { + expect(resp).toBe(environment.baseUrl + "report/wizard/security/getReportSecurityInfo"); + }); +}); + +it('should get getReportUserList', () => { + service.getReportUserList().subscribe((resp) => { + expect(resp).toBe(environment.baseUrl + "report/wizard/security/retrieveReportUserList"); + }); +}); + +it('should get getReportSecurityRoles', () => { + service.getReportSecurityRoles().subscribe((resp) => { + expect(resp).toBe(environment.baseUrl + "report/wizard/security/getReportSecurityRoles"); + }); +}); + +it('should get addReportUser', () => { + let userId = "test" + service.addReportUser(userId).subscribe((resp) => { + expect(resp).toBe(environment.baseUrl + "report/security/addReportUser"); + }); +}); + +it('should get removeReportUser', () => { + let userId = "test" + service.removeReportUser(userId).subscribe((resp) => { + expect(resp).toBe(environment.baseUrl + "report/security/removeReportUser"); + }); +}); + +it('should get addUserEditAccess', () => { + let userId = "test" + let readOnly = "dummy" + service.addUserEditAccess(userId, readOnly).subscribe((resp) => { + expect(resp).toBe(environment.baseUrl + "report/security/toggleUserEditAccess/"); + }); +}); + +it('should get addReportRole', () => { + let userId = "test" + service.addReportRole(userId).subscribe((resp) => { + expect(resp).toBe(environment.baseUrl + "report/security/addReportRole"); + }); +}); + +it('should get removeReportRole', () => { + let userId = "test" + service.removeReportRole(userId).subscribe((resp) => { + expect(resp).toBe(environment.baseUrl + "report/security/removeReportRole"); + }); +}); + +it('should get addRoleEditAccess', () => { + let userId = "test" + let readOnly = "dummy" + service.addRoleEditAccess(userId, readOnly).subscribe((resp) => { + expect(resp).toBe(environment.baseUrl + "report/security/toggleRoleEditAccess/"); + }); +}); + +it('should get saveSecurityTabInfo', () => { + let test : any; + service.saveSecurityTabInfo(test).subscribe((resp) => { + expect(resp).toBe(environment.baseUrl + "report/security/updateReportSecurityInfo"); + }); +}); + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.service.spec.ts index 57db6fb6..68978d90 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.service.spec.ts @@ -2,15 +2,36 @@ import { TestBed } from '@angular/core/testing'; import { SqlService } from './sql.service'; import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { HttpClient } from '@angular/common/http'; +import { environment } from 'src/environments/environment'; describe('SqlService', () => { - beforeEach(() => - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule] - })); + + let service: SqlService; + + beforeEach(() => {TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + providers: [SqlService, HttpClient, HttpClientTestingModule] + }) + service = TestBed.get(SqlService); +}); it('should be created', () => { const service: SqlService = TestBed.get(SqlService); expect(service).toBeTruthy(); }); + + it('should getSQLTabData', () => { + service.getSQLTabData("test").subscribe((res) => { + expect(res).toBe(environment); + }); + }); + + it('should postSQLValidateAndSave', () => { + service.postSQLValidateAndSave("test").subscribe((res) => { + expect(res).toBe(environment) + }); + }); + + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.html index c0611493..846dae52 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.html @@ -59,14 +59,16 @@ </div> </div> <div class="form-row"> - <label for="textinputID-3a">Organization User ID</label> + <label for="textinputID-3a">Organization User ID</label> <a style="cursor: hand;" target="_new" + href="http://webphone.att.com/cgi-bin/webphones.pl?id={{profile.orgUserId}}">wephone</a> <input [(ngModel)]="profile.orgUserId" type="text" name="orgUserId" class="form-control" id="orgUserId" style="width: 100%;" disabled="true"> </div> <div class="form-row"> <label for="textinputID-3a">Organization Manager ID</label> - + <a style="cursor: hand;" target="_new" + href="http://webphone.att.com/cgi-bin/webphones.pl?id={{profile.orgManagerUserId}}">wephone</a> <input [(ngModel)]="profile.orgManagerUserId" type="text" name="orgManagerUserId" class="form-control" id="orgManagerUserId" style=" @@ -195,33 +197,7 @@ </div> - <table mat-table [dataSource]="dataSource" matSort> - <ng-container matColumnDef="name"> - <th mat-header-cell *matHeaderCellDef id="heading1"> Name</th> - <td mat-cell *matCellDef="let rowData"> {{rowData.name}} </td> - </ng-container> - - <!--<ng-container matColumnDef="delete"> - <th mat-header-cell *matHeaderCellDef id="heading2"> Delete</th> - <td id="rowheader_t1_{{i}}" mat-cell *matCellDef="let rowData; let i=index;"> - <span class="icon-trash" id="{{i}}-button-role-remove" (click)="removeRole(rowData)"> - <i class="icon ion-md-trash"></i> - </span> - </td> - </ng-container>--> - - <!-- Active Column --> - <ng-container matColumnDef="active"> - <th id="col3" mat-header-cell *matHeaderCellDef>Active ?</th> - <td id="rowheader_t1_{{i}}-userId" mat-cell *matCellDef="let element; let i=index;"> - <mat-slide-toggle [(ngModel)]="element.selected" (change)="toggleRoles(element)"></mat-slide-toggle> - </td> - </ng-container> - - <tr mat-header-row *matHeaderRowDef="userRolesHeader"></tr> - <tr mat-row *matRowDef="let rowData; columns: userRolesHeader;"> - - </table> + <rdp-data-table [data]="ociavailableRoles" [settings]="settings"></rdp-data-table> <span class="ecomp-spinner" *ngIf="showSpinner"></span> </div> </div>
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.ts index 23a2bb07..45210f80 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.ts @@ -45,6 +45,7 @@ import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap'; import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; import { ErrorModalComponent } from 'src/app/modals/error-modal/error-modal.component'; import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; +import { Column, ColumnTypes, DataTableSettings } from 'portalsdk-tag-lib'; @Component({ selector: 'app-self', @@ -92,6 +93,9 @@ export class SelfComponent implements OnInit { selectedTimeZone; finalSelectedRoles: any; + public settings; + public columns: any = []; + ngOnInit() { this.showSpinner = false; @@ -145,7 +149,14 @@ export class SelfComponent implements OnInit { } } - this.dataSource = new MatTableDataSource(this.ociavailableRoles); + console.log("Data : ", this.ociavailableRoles); + this.columns.push(new Column("name", "Name", ColumnTypes.TEXT, false, null)); + this.settings = new DataTableSettings() + this.settings.columns = this.columns; + this.settings.isPaginationEnabled = false; + this.settings.isReadOnly = true; + this.settings.isTableSearchEnabled = false; + this.settings.isToggleEnabled = true; if (this.ociavailableRoles != null) { for (let role of this.ociavailableRoles) { diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/header/header.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/header/header.service.spec.ts index c93a83fb..c6a2de49 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/header/header.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/header/header.service.spec.ts @@ -1,17 +1,35 @@ import { TestBed } from '@angular/core/testing'; -import { HttpClientModule } from '@angular/common/http'; +import { HttpClientModule, HttpClient, HttpXhrBackend } from '@angular/common/http'; import { HeaderService } from './header.service'; +import { environment } from 'src/environments/environment'; +import { HttpTestingController } from '@angular/common/http/testing'; +import { get } from 'http'; + describe('HeaderService', () => { - beforeEach(() => TestBed.configureTestingModule({ - imports:[HttpClientModule] - })); + let service: HeaderService; + let httpMock: HttpTestingController; + + beforeEach(() =>{ TestBed.configureTestingModule({ + imports:[HttpClientModule], + providers: [HttpClient, HeaderService, HttpTestingController], + }); + service = TestBed.get(HeaderService); + httpMock = TestBed.get(HttpTestingController); +}); it('should be created', () => { const service: HeaderService = TestBed.get(HeaderService); expect(service).toBeTruthy(); }); + + it('should test getTopMenuItems', () => { + service.getTopMenuItems().subscribe((res) => { + expect(res).toBe(environment.getTopMenu); + }); + }) + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/sidebar/sidebar.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/sidebar/sidebar.service.spec.ts index 6e8a3ba6..255e4d81 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/sidebar/sidebar.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/sidebar/sidebar.service.spec.ts @@ -4,6 +4,8 @@ * =================================================================== * Copyright © 2019 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -36,17 +38,42 @@ * */ import { TestBed } from '@angular/core/testing'; -import { HttpClientModule } from '@angular/common/http'; +import { HttpClientModule, HttpClient } from '@angular/common/http'; import { SidebarService } from './sidebar.service'; +import { environment } from 'src/environments/environment'; +import { inject } from '@angular/core'; +import { HttpTestingController } from '@angular/common/http/testing'; describe('SidenavService', () => { - beforeEach(() => TestBed.configureTestingModule({ - imports: [HttpClientModule] - })); + + let service: SidebarService; + let httpMock: HttpTestingController; + + beforeEach(() => { TestBed.configureTestingModule({ + imports: [HttpClientModule], + providers: [SidebarService, HttpTestingController, HttpClient] + }); + + service = TestBed.get(SidebarService); + httpMock = TestBed.get(HttpTestingController); +}); it('should be created', () => { const service: SidebarService = TestBed.get(SidebarService); expect(service).toBeTruthy(); }); + + it('should test getLeftMenu method', () =>{ + service.getLeftMenu().subscribe((res) => { + expect(res).toBe(environment); + }); + }); + + it('should test getPage method', () =>{ + service.getPage("test").subscribe((res) => { + expect(res).toBe(environment.baseUrl+"test"); + }); +}); + }); |