[CST-7604] fixed as per tom comment to highlight Journal, Project, OrgUnit or Person) or is a Community or Collection

This commit is contained in:
Nikunj Sharma
2022-12-16 19:15:28 +05:30
parent 1ee3114432
commit 247e61ce2b
6 changed files with 20 additions and 7 deletions

View File

@@ -28,13 +28,14 @@ import { ItemSearchResultGridElementComponent } from './item-search-result-grid-
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
mockItemWithMetadata.hitHighlights = {};
const dcTitle = 'This is just another <em>title</em>';
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
bundles: createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [])),
metadata: {
'dc.title': [
{
language: 'en_US',
value: 'This is just another title'
value: dcTitle
}
],
'dc.contributor.author': [
@@ -154,6 +155,17 @@ export function getEntityGridElementTestComponent(component, searchResultWithMet
expect(itemAuthorField).toBeNull();
});
});
describe('When the item has title', () => {
beforeEach(() => {
comp.object = mockItemWithMetadata;
fixture.detectChanges();
});
it('should show highlighted title', () => {
const titleField = fixture.debugElement.query(By.css('.card-title'));
expect(titleField.nativeNode.innerHTML).toEqual(dcTitle);
});
});
});
};
}

View File

@@ -42,6 +42,7 @@ export class ItemSearchResultGridElementComponent extends SearchResultGridElemen
ngOnInit(): void {
super.ngOnInit();
this.itemPageRoute = getItemPageRoute(this.dso);
this.dsoTitle = this.dsoNameService.getName(this.dso);
this.dsoTitle = this.firstMetadataValue('dc.title') ??
(this.dso ? this.dsoNameService.getName(this.dso) : undefined);
}
}