[CST-7604] test cases update

This commit is contained in:
Nikunj Sharma
2023-01-11 02:46:20 +05:30
parent b7b2803f6e
commit 5660e7dc70
3 changed files with 282 additions and 7 deletions

View File

@@ -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>');
});
});
});
};
}