diff options
author | Indrijeet kumar <indriku1@in.ibm.com> | 2020-04-27 02:26:04 +0530 |
---|---|---|
committer | Indrijeet kumar <indriku1@in.ibm.com> | 2020-04-27 02:26:14 +0530 |
commit | e62e0c4031d0573411ea4fbc64170bfd8300b031 (patch) | |
tree | d391ad6bf3c88cc8ee2131e90eeaa88fc2673a89 /ecomp-sdk/epsdk-app-overlay/src/main | |
parent | 8c193243356e909d0210036006aa9416c6455d00 (diff) |
test cases in self component
some test cases in self component
Issue-ID: PORTAL-813
Change-Id: I53a1617552e03474cd7490c9df9fb8b786a61ad9
Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main')
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts | 49 |
1 files changed, 46 insertions, 3 deletions
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<SelfComponent>; 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); + }) + }); |