mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge remote-tracking branch 'origin/CST-7604' into CST-7604
This commit is contained in:
@@ -9,11 +9,19 @@ export class DSONameServiceMock {
|
|||||||
|
|
||||||
public getHitHighlights(object: any, dso: DSpaceObject) {
|
public getHitHighlights(object: any, dso: DSpaceObject) {
|
||||||
if (object.hitHighlights && object.hitHighlights['dc.title']) {
|
if (object.hitHighlights && object.hitHighlights['dc.title']) {
|
||||||
return object.hitHighlights['dc.title'][0];
|
return object.hitHighlights['dc.title'][0].value;
|
||||||
} else if (object.hitHighlights && object.hitHighlights['organization.legalName']) {
|
} else if (object.hitHighlights && object.hitHighlights['organization.legalName']) {
|
||||||
return object.hitHighlights['organization.legalName'][0];
|
return object.hitHighlights['organization.legalName'][0].value;
|
||||||
} else if (object.hitHighlights && (object.hitHighlights['person.familyName'] || object.hitHighlights['person.givenName'])) {
|
} else if (object.hitHighlights && (object.hitHighlights['person.familyName'] || object.hitHighlights['person.givenName'])) {
|
||||||
return `${object.hitHighlights['person.familyName'][0] || ''}, ${object.hitHighlights['person.givenName'][0] || ''}`;
|
if (object.hitHighlights['person.familyName'] && object.hitHighlights['person.givenName']) {
|
||||||
|
return `${object.hitHighlights['person.familyName'][0].value}, ${object.hitHighlights['person.givenName'][0].value}`;
|
||||||
|
}
|
||||||
|
if (object.hitHighlights['person.familyName']) {
|
||||||
|
return `${object.hitHighlights['person.familyName'][0].value}`;
|
||||||
|
}
|
||||||
|
if (object.hitHighlights['person.givenName']) {
|
||||||
|
return `${object.hitHighlights['person.givenName'][0].value}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return UNDEFINED_NAME;
|
return UNDEFINED_NAME;
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,9 @@ mockItemWithMetadata.hitHighlights = {};
|
|||||||
const dcTitle = 'This is just another <em>title</em>';
|
const dcTitle = 'This is just another <em>title</em>';
|
||||||
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
hitHighlights: {
|
hitHighlights: {
|
||||||
'dc.title': [dcTitle],
|
'dc.title': [{
|
||||||
|
value: dcTitle
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
bundles: createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [])),
|
bundles: createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [])),
|
||||||
metadata: {
|
metadata: {
|
||||||
@@ -61,6 +63,114 @@ mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const mockPerson: ItemSearchResult = Object.assign(new ItemSearchResult(), {
|
||||||
|
hitHighlights: {
|
||||||
|
'person.familyName': [{
|
||||||
|
value: '<em>Michel</em>'
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
indexableObject:
|
||||||
|
Object.assign(new Item(), {
|
||||||
|
bundles: createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [])),
|
||||||
|
entityType: 'Person',
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.contributor.author': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Smith, Donald'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.publisher': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'a publisher'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.date.issued': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: '2015-06-26'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.description.abstract': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is the abstract'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dspace.entity.type': [
|
||||||
|
{
|
||||||
|
value: 'Person'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'person.familyName': [
|
||||||
|
{
|
||||||
|
value: 'Michel'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
const mockOrgUnit: ItemSearchResult = Object.assign(new ItemSearchResult(), {
|
||||||
|
hitHighlights: {
|
||||||
|
'organization.legalName': [{
|
||||||
|
value: '<em>Science</em>'
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
indexableObject:
|
||||||
|
Object.assign(new Item(), {
|
||||||
|
bundles: createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [])),
|
||||||
|
entityType: 'OrgUnit',
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.contributor.author': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Smith, Donald'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.publisher': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'a publisher'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.date.issued': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: '2015-06-26'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.description.abstract': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is the abstract'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'organization.legalName': [
|
||||||
|
{
|
||||||
|
value: 'Science'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dspace.entity.type': [
|
||||||
|
{
|
||||||
|
value: 'OrgUnit'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
mockItemWithoutMetadata.hitHighlights = {};
|
mockItemWithoutMetadata.hitHighlights = {};
|
||||||
@@ -169,6 +279,30 @@ export function getEntityGridElementTestComponent(component, searchResultWithMet
|
|||||||
expect(titleField.nativeNode.innerHTML).toEqual(dcTitle);
|
expect(titleField.nativeNode.innerHTML).toEqual(dcTitle);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('When the item is Person and has title', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.object = mockPerson;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show highlighted title', () => {
|
||||||
|
const titleField = fixture.debugElement.query(By.css('.card-title'));
|
||||||
|
expect(titleField.nativeNode.innerHTML).toEqual('<em>Michel</em>');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('When the item is orgUnit and has title', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.object = mockOrgUnit;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show highlighted title', () => {
|
||||||
|
const titleField = fixture.debugElement.query(By.css('.card-title'));
|
||||||
|
expect(titleField.nativeNode.innerHTML).toEqual('<em>Science</em>');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,9 @@ let fixture: ComponentFixture<ItemSearchResultListElementComponent>;
|
|||||||
const dcTitle = 'This is just another <em>title</em>';
|
const dcTitle = 'This is just another <em>title</em>';
|
||||||
const mockItemWithMetadata: ItemSearchResult = Object.assign(new ItemSearchResult(), {
|
const mockItemWithMetadata: ItemSearchResult = Object.assign(new ItemSearchResult(), {
|
||||||
hitHighlights: {
|
hitHighlights: {
|
||||||
'dc.title': [dcTitle],
|
'dc.title': [{
|
||||||
|
value: dcTitle
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
indexableObject:
|
indexableObject:
|
||||||
Object.assign(new Item(), {
|
Object.assign(new Item(), {
|
||||||
@@ -25,7 +27,7 @@ const mockItemWithMetadata: ItemSearchResult = Object.assign(new ItemSearchResul
|
|||||||
'dc.title': [
|
'dc.title': [
|
||||||
{
|
{
|
||||||
language: 'en_US',
|
language: 'en_US',
|
||||||
value: 'This is just another title'
|
value: dcTitle
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'dc.contributor.author': [
|
'dc.contributor.author': [
|
||||||
@@ -62,7 +64,114 @@ const mockItemWithoutMetadata: ItemSearchResult = Object.assign(new ItemSearchRe
|
|||||||
metadata: {}
|
metadata: {}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
const mockPerson: ItemSearchResult = Object.assign(new ItemSearchResult(), {
|
||||||
|
hitHighlights: {
|
||||||
|
'person.familyName': [{
|
||||||
|
value: '<em>Michel</em>'
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
indexableObject:
|
||||||
|
Object.assign(new Item(), {
|
||||||
|
bundles: observableOf({}),
|
||||||
|
entityType: 'Person',
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.contributor.author': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Smith, Donald'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.publisher': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'a publisher'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.date.issued': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: '2015-06-26'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.description.abstract': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is the abstract'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'person.familyName': [
|
||||||
|
{
|
||||||
|
value: 'Michel'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dspace.entity.type': [
|
||||||
|
{
|
||||||
|
value: 'Person'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
const mockOrgUnit: ItemSearchResult = Object.assign(new ItemSearchResult(), {
|
||||||
|
hitHighlights: {
|
||||||
|
'organization.legalName': [{
|
||||||
|
value: '<em>Science</em>'
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
indexableObject:
|
||||||
|
Object.assign(new Item(), {
|
||||||
|
bundles: observableOf({}),
|
||||||
|
entityType: 'OrgUnit',
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.contributor.author': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Smith, Donald'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.publisher': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'a publisher'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.date.issued': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: '2015-06-26'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.description.abstract': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is the abstract'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'organization.legalName': [
|
||||||
|
{
|
||||||
|
value: 'Science'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dspace.entity.type': [
|
||||||
|
{
|
||||||
|
value: 'OrgUnit'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
const environmentUseThumbs = {
|
const environmentUseThumbs = {
|
||||||
browseBy: {
|
browseBy: {
|
||||||
showThumbnails: true
|
showThumbnails: true
|
||||||
@@ -220,6 +329,30 @@ describe('ItemSearchResultListElementComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('When the item is Person and has title', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
publicationListElementComponent.object = mockPerson;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show highlighted title', () => {
|
||||||
|
const titleField = fixture.debugElement.query(By.css('.item-list-title'));
|
||||||
|
expect(titleField.nativeNode.innerHTML).toEqual('<em>Michel</em>');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('When the item is orgUnit and has title', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
publicationListElementComponent.object = mockOrgUnit;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show highlighted title', () => {
|
||||||
|
const titleField = fixture.debugElement.query(By.css('.item-list-title'));
|
||||||
|
expect(titleField.nativeNode.innerHTML).toEqual('<em>Science</em>');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('When the item has no title', () => {
|
describe('When the item has no title', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
publicationListElementComponent.object = mockItemWithoutMetadata;
|
publicationListElementComponent.object = mockItemWithoutMetadata;
|
||||||
|
Reference in New Issue
Block a user