Improved test readibility and code

This commit is contained in:
Vito Albano
2016-10-12 17:12:00 +01:00
parent 1037385295
commit 90332daa64
12 changed files with 289 additions and 400 deletions

View File

@@ -2,6 +2,7 @@
text-align: center;
border-radius: 90%;
width: 40px;
height: 40px;
margin-right: 0%;
cursor: pointer;
border: 1px solid #999999;
@@ -16,6 +17,7 @@
.detail-user-profile-list-mdl{
margin-right: 10px;
padding: 0px 0;
}
.user-profile-list-mdl{

View File

@@ -22,7 +22,7 @@
<span class="mdl-list__item-primary-content">
<i class="mdl-list__item-avatar">
<img id="logged-user-img"
[src]="getEcmUserDetailAvatarUrl()"
[src]="getEcmUserAvatar()"
class="profile-image"/>
</i>
<span class="truncate-long-names">{{ecmUser.firstName}} {{ecmUser.lastName}}</span>
@@ -33,8 +33,8 @@
{{ ecmUser.jobTitle ? ecmUser.jobTitle : 'N/A' }}
</span>
</li>
<br>
</div>
<br>
<div *ngIf="bpmUser">
<hr class="title-start">
<span class="header-profile"><b>BPM</b></span>
@@ -42,7 +42,7 @@
<span class="mdl-list__item-primary-content">
<i class="mdl-list__item-avatar">
<img id="logged-user-img"
[src]="getBpmUserDetailAvatarUrl()"
[src]="getBpmUserAvatar()"
class="profile-image"/>
</i>
<span class="truncate-long-names">

View File

@@ -18,8 +18,8 @@
import { UserInfoComponent } from './user-info.component';
import { EcmUserService } from '../services/ecm-user.service';
import { BpmUserService } from '../services/bpm-user.service';
import { FakeEcmUserService } from '../testing/fake-ecm-user.service';
import { FakeBpmUserService } from '../testing/fake-bpm-user.service';
import { FakeEcmUserService } from '../assets/fake-ecm-user.service';
import { FakeBpmUserService } from '../assets/fake-bpm-user.service';
import { AlfrescoAuthenticationService, AlfrescoContentService } from 'ng2-alfresco-core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
@@ -107,7 +107,7 @@ describe('User info component', () => {
fixture.whenStable()
.then( () => {
fixture.detectChanges();
let res = userInfoComp.getEcmUserDetailAvatarUrl();
let res = userInfoComp.getEcmUserAvatar();
expect(userInfoComp.ecmUserImage).toBeUndefined();
expect(res).toEqual(userInfoComp.anonymouseImageUrl);
});
@@ -146,7 +146,7 @@ describe('User info component', () => {
fixture.whenStable()
.then( () => {
fixture.detectChanges();
let res = userInfoComp.getBpmUserDetailAvatarUrl();
let res = userInfoComp.getBpmUserAvatar();
expect(userInfoComp.bpmUserImage).toBeUndefined();
expect(res).toEqual(userInfoComp.anonymouseImageUrl);
});
@@ -194,10 +194,10 @@ describe('User info component', () => {
fixture.whenStable()
.then( () => {
fixture.detectChanges();
let resBpm = userInfoComp.getBpmUserDetailAvatarUrl();
let resBpm = userInfoComp.getBpmUserAvatar();
expect(userInfoComp.bpmUserImage).toBeUndefined();
expect(resBpm).toEqual(userInfoComp.anonymouseImageUrl);
let resEcm = userInfoComp.getEcmUserDetailAvatarUrl();
let resEcm = userInfoComp.getEcmUserAvatar();
expect(userInfoComp.ecmUserImage).toBeUndefined();
expect(resEcm).toEqual(userInfoComp.anonymouseImageUrl);
});

View File

@@ -45,43 +45,46 @@ export class UserInfoComponent implements OnInit {
}
ngOnInit() {
if ( this.authService.isEcmLoggedIn() ) {
if (this.authService.isEcmLoggedIn()) {
this.ecmUserService.getCurrentUserInfo()
.subscribe(
(res) => {
this.ecmUser = <EcmUserModel> res;
this.getEcmUserProfileImage();
}
);
this.ecmUser = <EcmUserModel> res;
this.getEcmAvatar();
}
);
}
if ( this.authService.isBpmLoggedIn() ) {
if (this.authService.isBpmLoggedIn()) {
this.bpmUserService.getCurrentUserInfo()
.subscribe(
(res) => {
this.bpmUser = <BpmUserModel> res;
this.getBpmUserProfileImage();
}
);
this.bpmUser = <BpmUserModel> res;
}
);
this.bpmUserService.getCurrentUserProfileImage()
.subscribe(
(res) => {
this.bpmUserImage = res;
}
);
}
}
private getBpmUserProfileImage() {
this.bpmUserImage = this.bpmUserService.getCurrentUserProfileImage();
}
private getEcmUserProfileImage() {
this.ecmUserImage = this.ecmUserService.getCurrentUserProfileImageUrl(this.ecmUser.avatarId);
private getEcmAvatar() {
this.ecmUserImage = this.ecmUserService.getUserProfileImage(this.ecmUser.avatarId);
}
public getUserAvatar() {
return this.ecmUserImage || this.bpmUserImage || this.anonymouseImageUrl;
return this.ecmUserImage || this.bpmUserImage || this.anonymouseImageUrl;
}
public getBpmUserDetailAvatarUrl() {
public getBpmUserAvatar() {
return this.bpmUserImage || this.anonymouseImageUrl;
}
public getEcmUserDetailAvatarUrl() {
public getEcmUserAvatar() {
return this.ecmUserImage || this.anonymouseImageUrl;
}