diff options
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts | 27 |
1 files changed, 25 insertions, 2 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 7418893a..4a12cd9f 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,9 @@ * =================================================================== * 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"); * you may not use this software except in compliance with the License. @@ -43,8 +45,11 @@ import { HttpClientModule } from '@angular/common/http'; import { HeaderComponent } from './header.component'; 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'; describe('HeaderComponent', () => { + let headerService:HeaderService; let component: HeaderComponent; let fixture: ComponentFixture<HeaderComponent>; @@ -56,6 +61,7 @@ describe('HeaderComponent', () => { RouterTestingModule, TranslateModule.forRoot(), HttpClientModule, + HttpClientTestingModule ], }) .compileComponents(); @@ -65,11 +71,28 @@ describe('HeaderComponent', () => { fixture = TestBed.createComponent(HeaderComponent); component = fixture.componentInstance; fixture.detectChanges(); + headerService = TestBed.get(HeaderService); }); 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(); + }) + } + }); }); |