test case written in header component 01/102201/1
authorIndrijeet kumar <indriku1@in.ibm.com>
Mon, 24 Feb 2020 07:48:36 +0000 (13:18 +0530)
committerIndrijeet kumar <indriku1@in.ibm.com>
Mon, 24 Feb 2020 07:48:49 +0000 (13:18 +0530)
test case written in header component

Issue-ID: PORTAL-813
Change-Id: I306a41b6a76f6d72cef1a921d99254963551d9e8
Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts

index 7418893..4a12cd9 100644 (file)
@@ -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();
+    })
+  }
+  });
 });