summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk
diff options
context:
space:
mode:
authorRupinder <rupinsi1@in.ibm.com>2020-02-26 14:35:58 +0530
committerRupinder <rupinsi1@in.ibm.com>2020-02-26 14:36:05 +0530
commit5d518fdc22faed5d8164c53af24550528c140a9b (patch)
tree56bb9e3a09a85f581bab06b4d7236083f1dd0736 /ecomp-sdk
parentf38b0f61055741546c86c1883c1aca88c5118056 (diff)
wrote test cases for header and sidebar service
writen test cases for header and sidebar service classses Issue-ID: PORTAL-834 Change-Id: I9ce29a0484df2b9246208a51cfcbafa57b2256f1 Signed-off-by: Rupinder <rupinsi1@in.ibm.com>
Diffstat (limited to 'ecomp-sdk')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/header/header.service.spec.ts26
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/sidebar/sidebar.service.spec.ts35
2 files changed, 53 insertions, 8 deletions
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");
+ });
+});
+
});