diff options
author | Lorraine Welch <lb2391@att.com> | 2020-04-01 16:35:46 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-04-01 16:35:46 +0000 |
commit | 174c6f17ef5f60a3035b6c18119d889c2c4deb9f (patch) | |
tree | 768aed81e0680c5e22dff958b37c5c051f287da3 | |
parent | 28c527421afcdc2accda1cdabdda23ba33784f4e (diff) | |
parent | e3d10020fa178a7bca5446caaaa3d257c249cc1e (diff) |
Merge "test cases written in header component"
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts | 31 |
1 files changed, 19 insertions, 12 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 ecfd694d..1253b2be 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 @@ -37,20 +37,21 @@ * * */ -import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { TranslateModule } from '@ngx-translate/core'; +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'; 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; @@ -66,15 +67,13 @@ describe('HeaderComponent', () => { LayoutModule, RouterTestingModule, TranslateModule.forRoot(), + HttpClientModule, HttpClientTestingModule ], - providers:[CookieService,HeaderService,MockBackend, BaseRequestOptions, { - provide: Http, - useFactory: (backend: MockBackend, defaultOptions: BaseRequestOptions) => { - return new Http(backend, defaultOptions); - }, - deps: [MockBackend, BaseRequestOptions], - }] + providers:[ + CookieService, + HeaderService + ] }) .compileComponents(); })); @@ -92,6 +91,12 @@ describe('HeaderComponent', () => { expect(component).toBeTruthy(); }); + it('testing if condition in ngOnInit method',()=>{ + component.cookieService.set('show_app_header','false'); + component.ngOnInit(); + expect(component.showHeader).toBe(false) + }) + describe('should test ngOnInit',()=>{ it('should validate on ngOnInit',()=>{ let spy=spyOn(headerService, 'getTopMenuItems').and.returnValue(Observable.of('you object')); @@ -113,4 +118,6 @@ describe('HeaderComponent', () => { it('should test on onLoggedout method',()=>{ expect(localStorage.getItem('isLoggedin')).toBeFalsy }) -});
\ No newline at end of file + + +}); |