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/layout/components/header/header.component.spec.ts61
1 files changed, 42 insertions, 19 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts
index 4a12cd9f..ecbbcc60 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts
@@ -4,7 +4,7 @@
* ===================================================================
* Copyright © 2019 AT&T Intellectual Property. All rights reserved.
* ===================================================================
- * Modification Copyright © 2020 IBM.
+ * * Modification Copyright © 2020 IBM.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -37,7 +37,7 @@
*
*
*/
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core';
import { HttpClientModule } from '@angular/common/http';
@@ -47,15 +47,23 @@ import { LayoutModule } from '../../layout.module';
import { CookieService } from 'ngx-cookie-service';
import { HeaderService } from 'src/app/shared/services/header/header.service';
import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { Router } from '@angular/router';
+import { MockBackend, MockConnection } from '@angular/http/testing';
+//import { observable, Observable } from 'rxjs';
+import 'rxjs/add/observable/of';
+import { Observable } from 'rxjs/Observable';
+import { BaseRequestOptions, Http } from '@angular/http';
describe('HeaderComponent', () => {
let headerService:HeaderService;
+ let cookieService:CookieService;
+ let router:Router;
let component: HeaderComponent;
let fixture: ComponentFixture<HeaderComponent>;
+ let spy: any;
beforeEach(async(() => {
TestBed.configureTestingModule({
- providers:[CookieService],
imports: [
LayoutModule,
RouterTestingModule,
@@ -63,6 +71,13 @@ describe('HeaderComponent', () => {
HttpClientModule,
HttpClientTestingModule
],
+ providers:[CookieService,HeaderService,MockBackend, BaseRequestOptions, {
+ provide: Http,
+ useFactory: (backend: MockBackend, defaultOptions: BaseRequestOptions) => {
+ return new Http(backend, defaultOptions);
+ },
+ deps: [MockBackend, BaseRequestOptions],
+ }]
})
.compileComponents();
}));
@@ -72,27 +87,35 @@ describe('HeaderComponent', () => {
component = fixture.componentInstance;
fixture.detectChanges();
headerService = TestBed.get(HeaderService);
+ cookieService=TestBed.get(CookieService);
+
});
it('should create', () => {
expect(component).toBeTruthy();
});
- it('should test ngOnInit method',()=>{
- fixture.detectChanges();
- component.ngOnInit();
- if(component.cookieService.get('show_app_header')=='false')
- expect(component.showHeader).toBe(false);
- expect(component.pushRightClass).toEqual('push-right');
- (done: DoneFn)=> {
- headerService.getTopMenuItems().subscribe(res=>{
- expect(component.response).toEqual(res);
- expect(component.userFirstName).toBe(component.response.firstName);
- expect(component.userEmail).toBe(component.response.email);
- expect(component.userId).toBe(component.response.userId);
- expect(component.userName).toBe(component.response.userName);
- done();
+ describe('should test ngOnInit',()=>{
+ it('should validate on ngOnInit',()=>{
+ let spy=spyOn(headerService, 'getTopMenuItems').and.returnValue(Observable.of('you object'));
+ component.ngOnInit();
+ expect(spy).toHaveBeenCalled();
})
- }
- });
+ })
+
+
+ it('should test isToggled method',()=>{
+ expect(component.isToggled()).toBe(false);
+ })
+
+ it('should test toggleSidebar method',()=>{
+ component.pushRightClass="kumar";
+ expect(component.toggleSidebar()).toBeUndefined;
+ })
+
+ it('should test on onLoggedout method',()=>{
+ expect(localStorage.getItem('isLoggedin')).toBeFalsy
+ })
+
+
});