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) {
|
||||
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']) {
|
||||
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'])) {
|
||||
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;
|
||||
}
|
||||
|
@@ -31,7 +31,9 @@ mockItemWithMetadata.hitHighlights = {};
|
||||
const dcTitle = 'This is just another <em>title</em>';
|
||||
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||
hitHighlights: {
|
||||
'dc.title': [dcTitle],
|
||||
'dc.title': [{
|
||||
value: dcTitle
|
||||
}],
|
||||
},
|
||||
bundles: createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [])),
|
||||
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();
|
||||
mockItemWithoutMetadata.hitHighlights = {};
|
||||
@@ -169,6 +279,30 @@ export function getEntityGridElementTestComponent(component, searchResultWithMet
|
||||
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 mockItemWithMetadata: ItemSearchResult = Object.assign(new ItemSearchResult(), {
|
||||
hitHighlights: {
|
||||
'dc.title': [dcTitle],
|
||||
'dc.title': [{
|
||||
value: dcTitle
|
||||
}],
|
||||
},
|
||||
indexableObject:
|
||||
Object.assign(new Item(), {
|
||||
@@ -25,7 +27,7 @@ const mockItemWithMetadata: ItemSearchResult = Object.assign(new ItemSearchResul
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
value: dcTitle
|
||||
}
|
||||
],
|
||||
'dc.contributor.author': [
|
||||
@@ -62,7 +64,114 @@ const mockItemWithoutMetadata: ItemSearchResult = Object.assign(new ItemSearchRe
|
||||
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 = {
|
||||
browseBy: {
|
||||
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', () => {
|
||||
beforeEach(() => {
|
||||
publicationListElementComponent.object = mockItemWithoutMetadata;
|
||||
|
Reference in New Issue
Block a user