summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIndrijeet kumar <indriku1@in.ibm.com>2020-05-01 07:06:33 +0530
committerIndrijeet kumar <indriku1@in.ibm.com>2020-05-01 07:06:38 +0530
commit7b1f8693226c311327d194e1c0e8f6d2a5835697 (patch)
treeca60190121a40df44cecad37d596af912383b3bb
parentc7f033eec8a0a88a2ae0d200b5cc5f25fe41e70f (diff)
some test cases in self component
some test cases in self component Issue-ID: PORTAL-813 Change-Id: Ie070d510adf1eaf4125d459f76032d7482a1629d Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts66
1 files changed, 52 insertions, 14 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 5178b52b..52bb01f0 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
@@ -48,29 +48,30 @@ 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';
-import { ActivatedRoute } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
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';
+import { ErrorModalComponent } from 'src/app/modals/error-modal/error-modal.component';
+import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
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,InformationModalComponent ],
+ declarations: [
+ SelfComponent,
+ InformationModalComponent,
+ ErrorModalComponent,
+ ConfirmationModalComponent
+ ],
imports: [
ReactiveFormsModule,
FormsModule,
@@ -85,7 +86,10 @@ describe('SelfComponent', () => {
})
TestBed.overrideModule(BrowserDynamicTestingModule,{
set:{
- entryComponents:[InformationModalComponent ]
+ entryComponents:[
+ InformationModalComponent,
+ ErrorModalComponent,
+ ConfirmationModalComponent]
}
})
.compileComponents();
@@ -103,9 +107,6 @@ describe('SelfComponent', () => {
expect(component).toBeTruthy();
});
- // it('should test assignProfileDetails method',()=>{
- // component.assignProfileDetails(data);
- // })
describe('should test ngOnInit method',()=>{
it('should test subscribe',()=>{
@@ -133,9 +134,46 @@ describe('SelfComponent', () => {
expect(spy).toHaveBeenCalled();
})
- // // it('should test saveProfile method',()=>{
- // // component.saveProfile()
- // // })
+ it('should test saveProfile method first if condition',()=>{
+ component.oriProfile={"loginId":"loginId1"};
+ component.profile.loginId="loginId2";
+ component.saveProfile()
+ })
+
+ it('should test saveProfile method second if condition',()=>{
+ component.oriProfile={
+ "loginId":"loginId",
+ "loginPwd":"loginPwd1"
+ };
+ component.profile.loginId="loginId";
+ component.profile.loginPwd="loginPwd2"
+ component.saveProfile()
+ })
+
+ it('should test saveProfile method',()=>{
+ component.oriProfile={
+ "loginId":"loginId",
+ "loginPwd":"loginPwd"
+ };
+ component.profile.loginId="loginId";
+ component.profile.loginPwd="loginPwd";
+ component.stateList=[{"value":"value"}];
+ component.profile.state="value";
+ component.ociCountries=[{"value":"India"}];
+ component.profile.country="India";
+ component.ociTimeZones=[{"value":"Indian"}];
+ component.profile.timeZoneId="Indian";
+ component.postData={
+ profile: "profile",
+ selectedCountry:"selectedCountry",
+ selectedState:"selectedState",
+ selectedTimeZone:"selectedTimeZone"
+ };
+ component.profileId="profileId";
+ let spy= spyOn(profileService,'saveProfile').and.returnValue(Observable.of('your object'));
+ component.saveProfile()
+ expect(spy).toHaveBeenCalled();
+ });
it('should test toggleRoles method',()=>{
component.ociavailableRoles=[{"ociavailableRoles":"ociavailableRoles"}];