From 39cb4ff5d211c5d12b2368f5076d5a927ad74740 Mon Sep 17 00:00:00 2001 From: Indrijeet kumar Date: Wed, 4 Mar 2020 16:46:27 +0530 Subject: testing ngOnInit case for self component testing ngOnInit in self component Issue-ID: PORTAL-813 Change-Id: Ib9e9a2819168415d45d9b17872ebdffe6adab247 Signed-off-by: Indrijeet Kumar --- .../src/app/pages/ext/profile/self/self.component.spec.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'ecomp-sdk/epsdk-app-overlay') diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts index d87afceb..7481acc8 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts @@ -46,10 +46,14 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { MatTableModule, MatSelectModule, MatSlideToggleModule } from '@angular/material'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { UserService } from 'src/app/shared/services/user/user.service'; +import { Observable } from 'rxjs'; describe('SelfComponent', () => { let component: SelfComponent; let fixture: ComponentFixture; + let userService:UserService; + let tableobj:any=JSON.stringify({"errormessage":"DummyError","stacktrace":"trace"}); beforeEach(async(() => { TestBed.configureTestingModule({ @@ -72,9 +76,19 @@ describe('SelfComponent', () => { fixture = TestBed.createComponent(SelfComponent); component = fixture.componentInstance; fixture.detectChanges(); + userService=TestBed.get(UserService); }); it('should create', () => { expect(component).toBeTruthy(); }); + + describe('should test ngOnInit method',()=>{ + it('should test subscribe',()=>{ + let spy=spyOn(userService,'getFunctionalMenuStaticDetailSession').and.returnValue(Observable.of('you object')); + component.ngOnInit(); + expect(spy).toHaveBeenCalled(); + }) + }) + }); -- cgit 1.2.3-korg