mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
fix userinfo test (#1819)
* fix userinfo test * Added changes from review
This commit is contained in:
parent
0fcd40b7f0
commit
09f3a6e30f
@ -34,16 +34,16 @@ export let fakeEcmCompany: EcmCompanyModel = {
|
|||||||
|
|
||||||
export let fakeEcmUser = {
|
export let fakeEcmUser = {
|
||||||
id: 'fake-id',
|
id: 'fake-id',
|
||||||
firstName: 'fake-first-name',
|
firstName: 'fake-ecm-first-name',
|
||||||
lastName: 'fake-last-name',
|
lastName: 'fake-ecm-last-name',
|
||||||
description: 'i am a fake user for test',
|
description: 'i am a fake user for test',
|
||||||
avatarId: 'fake-avatar-id',
|
avatarId: 'fake-avatar-id',
|
||||||
email: 'fakeEcm@ecmUser.com',
|
email: 'fakeEcm@ecmUser.com',
|
||||||
skypeId: 'fake-skype-id',
|
skypeId: 'fake-skype-id',
|
||||||
googleId: 'fake-googleId-id',
|
googleId: 'fake-googleId-id',
|
||||||
instantMessageId: 'fake-instantMessageId-id',
|
instantMessageId: 'fake-instantMessageId-id',
|
||||||
company: fakeEcmCompany,
|
company: null,
|
||||||
jobTitle: 'test job',
|
jobTitle: 'job-ecm-test',
|
||||||
location: 'fake location',
|
location: 'fake location',
|
||||||
mobile: '000000000',
|
mobile: '000000000',
|
||||||
telephone: '11111111',
|
telephone: '11111111',
|
||||||
@ -58,13 +58,13 @@ export let fakeEcmUserNoImage = {
|
|||||||
firstName: 'fake-first-name',
|
firstName: 'fake-first-name',
|
||||||
lastName: 'fake-last-name',
|
lastName: 'fake-last-name',
|
||||||
description: 'i am a fake user for test',
|
description: 'i am a fake user for test',
|
||||||
avatarId: undefined,
|
avatarId: null,
|
||||||
email: 'fakeEcm@ecmUser.com',
|
email: 'fakeEcm@ecmUser.com',
|
||||||
skypeId: 'fake-skype-id',
|
skypeId: 'fake-skype-id',
|
||||||
googleId: 'fake-googleId-id',
|
googleId: 'fake-googleId-id',
|
||||||
instantMessageId: 'fake-instantMessageId-id',
|
instantMessageId: 'fake-instantMessageId-id',
|
||||||
company: fakeEcmCompany,
|
company: null,
|
||||||
jobTitle: 'test job',
|
jobTitle: null,
|
||||||
location: 'fake location',
|
location: 'fake location',
|
||||||
mobile: '000000000',
|
mobile: '000000000',
|
||||||
telephone: '11111111',
|
telephone: '11111111',
|
||||||
@ -76,7 +76,7 @@ export let fakeEcmUserNoImage = {
|
|||||||
|
|
||||||
export let fakeEcmEditedUser = {
|
export let fakeEcmEditedUser = {
|
||||||
id: 'fake-id',
|
id: 'fake-id',
|
||||||
firstName: 'fake-first-name',
|
firstName: null,
|
||||||
lastName: 'fake-last-name',
|
lastName: 'fake-last-name',
|
||||||
description: 'i am a fake user for test',
|
description: 'i am a fake user for test',
|
||||||
avatarId: 'fake-avatar-id',
|
avatarId: 'fake-avatar-id',
|
||||||
@ -84,7 +84,7 @@ export let fakeEcmEditedUser = {
|
|||||||
skypeId: 'fake-skype-id',
|
skypeId: 'fake-skype-id',
|
||||||
googleId: 'fake-googleId-id',
|
googleId: 'fake-googleId-id',
|
||||||
instantMessageId: 'fake-instantMessageId-id',
|
instantMessageId: 'fake-instantMessageId-id',
|
||||||
company: fakeEcmCompany,
|
company: null,
|
||||||
jobTitle: 'test job',
|
jobTitle: 'test job',
|
||||||
location: 'fake location',
|
location: 'fake location',
|
||||||
mobile: '000000000',
|
mobile: '000000000',
|
||||||
|
@ -28,6 +28,7 @@ import {
|
|||||||
} from 'ng2-alfresco-core';
|
} from 'ng2-alfresco-core';
|
||||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||||
import { BpmUserModel } from './../models/bpm-user.model';
|
import { BpmUserModel } from './../models/bpm-user.model';
|
||||||
|
import { fakeEcmUser, fakeEcmEditedUser, fakeEcmUserNoImage } from '../assets/fake-ecm-user.service.mock';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
@ -65,11 +66,6 @@ describe('User info component', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
fixture.destroy();
|
|
||||||
TestBed.resetTestingModule();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not show any image if the user is not logged in', () => {
|
it('should not show any image if the user is not logged in', () => {
|
||||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||||
expect(element.querySelector('#logged-user-img')).toBeNull();
|
expect(element.querySelector('#logged-user-img')).toBeNull();
|
||||||
@ -97,9 +93,6 @@ describe('User info component', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(stubAuthService, 'isEcmLoggedIn').and.returnValue(true);
|
spyOn(stubAuthService, 'isEcmLoggedIn').and.returnValue(true);
|
||||||
spyOn(stubAuthService, 'isLoggedIn').and.returnValue(true);
|
spyOn(stubAuthService, 'isLoggedIn').and.returnValue(true);
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
jasmine.Ajax.install();
|
jasmine.Ajax.install();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -111,17 +104,8 @@ describe('User info component', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 200,
|
status: 200,
|
||||||
contentType: 'json',
|
contentType: 'application/json',
|
||||||
responseText: {
|
responseText: JSON.stringify({ entry: fakeEcmEditedUser })
|
||||||
'entry': {
|
|
||||||
'id': 'fake-id',
|
|
||||||
'firstName': null,
|
|
||||||
'lastName': 'fake-ecm-last-name',
|
|
||||||
'description': 'i am a fake user for test',
|
|
||||||
'avatarId': 'fake-avatar-id',
|
|
||||||
'email': 'fakeEcm@ecmUser.com'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
@ -140,58 +124,43 @@ describe('User info component', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 200,
|
status: 200,
|
||||||
contentType: 'json',
|
contentType: 'application/json',
|
||||||
responseText: {
|
responseText: JSON.stringify({ entry: fakeEcmUser })
|
||||||
'entry': {
|
|
||||||
'id': 'fake-id',
|
|
||||||
'firstName': 'fake-ecm-first-name',
|
|
||||||
'lastName': 'fake-ecm-last-name',
|
|
||||||
'description': 'i am a fake user for test',
|
|
||||||
'avatarId': 'fake-avatar-id',
|
|
||||||
'email': 'fakeEcm@ecmUser.com'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should get the ecm current user image from the service', async(() => {
|
it('should get the ecm current user image from the service', async(() => {
|
||||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
fixture.whenStable().then(() => {
|
||||||
expect(element.querySelector('#logged-user-img')).toBeDefined();
|
fixture.detectChanges();
|
||||||
expect(element.querySelector('#logged-user-img').getAttribute('src')).toContain('assets/images/ecmImg.gif');
|
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||||
|
expect(element.querySelector('#logged-user-img')).toBeDefined();
|
||||||
|
expect(element.querySelector('#logged-user-img').getAttribute('src')).toContain('assets/images/ecmImg.gif');
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should get the ecm user informations from the service', async(() => {
|
it('should get the ecm user informations from the service', () => {
|
||||||
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
fixture.whenStable().then(() => {
|
||||||
expect(element.querySelector('#ecm_username')).toBeDefined();
|
fixture.detectChanges();
|
||||||
expect(element.querySelector('#ecm_title')).toBeDefined();
|
expect(element.querySelector('#userinfo_container')).toBeDefined();
|
||||||
expect(element.querySelector('#ecm-user-detail-image')).toBeDefined();
|
expect(element.querySelector('#ecm_username')).toBeDefined();
|
||||||
expect(element.querySelector('#ecm-user-detail-image').getAttribute('src')).toContain('assets/images/ecmImg.gif');
|
expect(element.querySelector('#ecm_title')).toBeDefined();
|
||||||
expect(element.querySelector('#ecm-full-name').textContent).toContain('fake-ecm-first-name fake-ecm-last-name');
|
expect(element.querySelector('#ecm-user-detail-image')).toBeDefined();
|
||||||
expect(element.querySelector('#ecm-job-title').textContent).toContain('USER_PROFILE.LABELS.ECM.JOB_TITLE');
|
expect(element.querySelector('#ecm-user-detail-image').getAttribute('src')).toContain('assets/images/ecmImg.gif');
|
||||||
}));
|
expect(element.querySelector('#ecm-full-name').textContent).toContain('fake-ecm-first-name fake-ecm-last-name');
|
||||||
|
expect(element.querySelector('#ecm-job-title').textContent).toContain('USER_PROFILE.LABELS.ECM.JOB_TITLE');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('and has no image', () => {
|
describe('and has no image', () => {
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
userInfoComp.anonymousImageUrl = userInfoComp.anonymousImageUrl.replace('/base/dist', '');
|
userInfoComp.anonymousImageUrl = userInfoComp.anonymousImageUrl.replace('/base/dist', '');
|
||||||
spyOn(stubContent, 'getContentUrl').and.returnValue('wrongImage.gif');
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 200,
|
status: 200,
|
||||||
contentType: 'json',
|
contentType: 'application/json',
|
||||||
responseText: {
|
responseText: JSON.stringify({ entry: fakeEcmUserNoImage })
|
||||||
'entry': {
|
|
||||||
'id': 'fake-id',
|
|
||||||
'firstName': 'fake-first-name',
|
|
||||||
'lastName': 'fake-last-name',
|
|
||||||
'description': 'i am a fake user for test',
|
|
||||||
'email': 'fakeEcm@ecmUser.com'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -306,26 +275,14 @@ describe('User info component', () => {
|
|||||||
spyOn(stubContent, 'getContentUrl').and.returnValue('src/assets/images/ecmImg.gif');
|
spyOn(stubContent, 'getContentUrl').and.returnValue('src/assets/images/ecmImg.gif');
|
||||||
userInfoComp.anonymousImageUrl = userInfoComp.anonymousImageUrl.replace('/base/dist', '');
|
userInfoComp.anonymousImageUrl = userInfoComp.anonymousImageUrl.replace('/base/dist', '');
|
||||||
jasmine.Ajax.install();
|
jasmine.Ajax.install();
|
||||||
fakeBpmUser.firstName = 'fake-bpm-first-name';
|
|
||||||
fakeBpmUser.lastName = 'fake-bpm-last-name';
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
jasmine.Ajax.requests.first().respondWith({
|
jasmine.Ajax.requests.first().respondWith({
|
||||||
status: 200,
|
status: 200,
|
||||||
contentType: 'json',
|
contentType: 'application/json',
|
||||||
responseText: {
|
responseText: JSON.stringify({ entry: fakeEcmUser })
|
||||||
'entry': {
|
|
||||||
'id': 'fake-id',
|
|
||||||
'firstName': 'fake-ecm-first-name',
|
|
||||||
'lastName': 'fake-ecm-last-name',
|
|
||||||
'description': 'i am a fake user for test',
|
|
||||||
'avatarId': 'fake-ecm-avatar-id',
|
|
||||||
'email': 'fakeEcm@ecmUser.com',
|
|
||||||
'jobTitle': 'job-ecm-test'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 200,
|
status: 200,
|
||||||
|
@ -71,8 +71,8 @@ describe('EcmUserService', () => {
|
|||||||
service.getCurrentUserInfo().subscribe(
|
service.getCurrentUserInfo().subscribe(
|
||||||
(user) => {
|
(user) => {
|
||||||
expect(user).toBeDefined();
|
expect(user).toBeDefined();
|
||||||
expect(user.firstName).toEqual('fake-first-name');
|
expect(user.firstName).toEqual('fake-ecm-first-name');
|
||||||
expect(user.lastName).toEqual('fake-last-name');
|
expect(user.lastName).toEqual('fake-ecm-last-name');
|
||||||
expect(user.email).toEqual('fakeEcm@ecmUser.com');
|
expect(user.email).toEqual('fakeEcm@ecmUser.com');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user