From e62e0c4031d0573411ea4fbc64170bfd8300b031 Mon Sep 17 00:00:00 2001 From: Indrijeet kumar Date: Mon, 27 Apr 2020 02:26:04 +0530 Subject: test cases in self component some test cases in self component Issue-ID: PORTAL-813 Change-Id: I53a1617552e03474cd7490c9df9fb8b786a61ad9 Signed-off-by: Indrijeet Kumar --- .../pages/ext/profile/self/self.component.spec.ts | 49 ++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) (limited to 'ecomp-sdk/epsdk-app-overlay/src/main') 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 ee8f7b64..5178b52b 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 @@ -50,18 +50,27 @@ import { UserService } from 'src/app/shared/services/user/user.service'; import { Observable } from 'rxjs'; import { ActivatedRoute } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; -import { ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap'; +import { ModalDismissReasons, NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { ProfileService } from '../profile.service'; +import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; +import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; describe('SelfComponent', () => { let component: SelfComponent; let fixture: ComponentFixture; let userService:UserService; + let profileService:ProfileService; let tableobj:any=JSON.stringify({"errormessage":"DummyError","stacktrace":"trace"}); + let data={"data":'{"profile":\'{"data":"data"}\'}'}; + //var _element={"_element":true}; + var _element={"_element":{"selected":true}} + + beforeEach(async(() => { TestBed.configureTestingModule({ schemas: [CUSTOM_ELEMENTS_SCHEMA], - declarations: [ SelfComponent ], + declarations: [ SelfComponent,InformationModalComponent ], imports: [ ReactiveFormsModule, FormsModule, @@ -70,9 +79,15 @@ describe('SelfComponent', () => { MatSlideToggleModule, BrowserAnimationsModule, HttpClientTestingModule, - RouterTestingModule + RouterTestingModule, + NgbModule.forRoot() ] }) + TestBed.overrideModule(BrowserDynamicTestingModule,{ + set:{ + entryComponents:[InformationModalComponent ] + } + }) .compileComponents(); })); @@ -81,12 +96,17 @@ describe('SelfComponent', () => { component = fixture.componentInstance; fixture.detectChanges(); userService=TestBed.get(UserService); + profileService=TestBed.get(ProfileService); }); it('should create', () => { expect(component).toBeTruthy(); }); + // it('should test assignProfileDetails method',()=>{ + // component.assignProfileDetails(data); + // }) + describe('should test ngOnInit method',()=>{ it('should test subscribe',()=>{ let spy=spyOn(userService,'getFunctionalMenuStaticDetailSession').and.returnValue(Observable.of('you object')); @@ -101,4 +121,27 @@ describe('SelfComponent', () => { component['getDismissReason'](""); }) + it('should test getProfileById method',()=>{ + let spy=spyOn(profileService,'getProfileById').and.callThrough(); + component.getProfileById("indrijeet"); + expect(spy).toHaveBeenCalled(); + }) + + it('should test getSelfProfileDetail method',()=>{ + let spy=spyOn(profileService,'getSelfProfile').and.callThrough(); + component.getSelfProfileDetail(); + expect(spy).toHaveBeenCalled(); + }) + + // // it('should test saveProfile method',()=>{ + // // component.saveProfile() + // // }) + + it('should test toggleRoles method',()=>{ + component.ociavailableRoles=[{"ociavailableRoles":"ociavailableRoles"}]; + component.finalSelectedRoles=[{"finalSelectedRoles":"finalSelectedRoles"}]; + component.toggleRoles(_element); + component.addUserRole(_element); + }) + }); -- cgit 1.2.3-korg