mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-1945] Profile image has Initials displayed behind it. (#2648)
* Refactored userInfo component. * Added test cases.
This commit is contained in:
committed by
Eugenio Romano
parent
8a52d6fed5
commit
15cbd3a316
@@ -16,8 +16,9 @@
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { By, DomSanitizer } from '@angular/platform-browser';
|
||||
import { AuthenticationService, ContentService } from '../../services';
|
||||
import { InitialUsernamePipe } from '../../pipes';
|
||||
import { fakeBpmUser } from '../../mock/bpm-user.service.mock';
|
||||
import { fakeEcmEditedUser, fakeEcmUser, fakeEcmUserNoImage } from '../../mock/ecm-user.service.mock';
|
||||
import { MaterialModule } from '../../material.module';
|
||||
@@ -26,6 +27,37 @@ import { EcmUserService } from '../services/ecm-user.service';
|
||||
import { BpmUserModel } from './../models/bpm-user.model';
|
||||
import { UserInfoComponent } from './user-info.component';
|
||||
|
||||
class FakeSanitazer extends DomSanitizer {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
sanitize(html) {
|
||||
return html;
|
||||
}
|
||||
|
||||
bypassSecurityTrustHtml(value: string): any {
|
||||
return value;
|
||||
}
|
||||
|
||||
bypassSecurityTrustStyle(value: string): any {
|
||||
return null;
|
||||
}
|
||||
|
||||
bypassSecurityTrustScript(value: string): any {
|
||||
return null;
|
||||
}
|
||||
|
||||
bypassSecurityTrustUrl(value: string): any {
|
||||
return null;
|
||||
}
|
||||
|
||||
bypassSecurityTrustResourceUrl(value: string): any {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('User info component', () => {
|
||||
@@ -189,6 +221,20 @@ describe('User info component', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display the current user image if user has avatarId', async(() => {
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let imageButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#logged-user-img');
|
||||
imageButton.click();
|
||||
fixture.detectChanges();
|
||||
let loggedImage = fixture.debugElement.query(By.css('#logged-user-img'));
|
||||
expect(userInfoComp.ecmUser.avatarId).toBe('fake-avatar-id');
|
||||
expect(element.querySelector('#userinfo_container')).not.toBeNull();
|
||||
expect(loggedImage).not.toBeNull();
|
||||
expect(loggedImage.properties.src).toContain('assets/images/ecmImg.gif');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should get the ecm user informations from the service', () => {
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
@@ -239,6 +285,20 @@ describe('User info component', () => {
|
||||
let tabHeader = fixture.debugElement.query(By.css('#tab-group-env'));
|
||||
expect(tabHeader.classes['adf-hide-tab']).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should display the current user Initials if the user dose not have avatarId', async(() => {
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let pipe = new InitialUsernamePipe(new FakeSanitazer());
|
||||
expect(userInfoComp.ecmUser.avatarId).toBeNull();
|
||||
expect(pipe.transform({
|
||||
id: 13,
|
||||
firstName: 'Wilbur',
|
||||
lastName: 'Adams',
|
||||
email: 'wilbur@app.com'
|
||||
})).toBe('<div id="user-initials-image" class="">WA</div>');
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user