From 142ab2f44aae317a05de60908c0b259c73b79f6e Mon Sep 17 00:00:00 2001 From: Indrijeet kumar Date: Mon, 24 Feb 2020 13:18:36 +0530 Subject: test case written in header component test case written in header component Issue-ID: PORTAL-813 Change-Id: I306a41b6a76f6d72cef1a921d99254963551d9e8 Signed-off-by: Indrijeet Kumar --- .../components/header/header.component.spec.ts | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'ecomp-sdk/epsdk-app-overlay/src/main') 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; @@ -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(); + }) + } + }); }); -- cgit 1.2.3-korg