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);
+ });
+ })
+
});
* ===================================================================
* 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");
*
*/
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");
+ });
+});
+
});