diff --git a/src/app/item-page/field-components/metadata-values/metadata-values.component.spec.ts b/src/app/item-page/field-components/metadata-values/metadata-values.component.spec.ts index 23f80982077..de46cd9e4c8 100644 --- a/src/app/item-page/field-components/metadata-values/metadata-values.component.spec.ts +++ b/src/app/item-page/field-components/metadata-values/metadata-values.component.spec.ts @@ -73,4 +73,20 @@ describe('MetadataValuesComponent', () => { expect(comp.hasLink(mdValue)).toBe(true); }); + it('should return correct target and rel for internal links', () => { + spyOn(comp, 'hasInternalLink').and.returnValue(true); + const urlValue = '/internal-link'; + const result = comp.getLinkAttributes(urlValue); + expect(result.target).toBe('_self'); + expect(result.rel).toBe(''); + }); + + it('should return correct target and rel for external links', () => { + spyOn(comp, 'hasInternalLink').and.returnValue(false); + const urlValue = 'https://www.dspace.org'; + const result = comp.getLinkAttributes(urlValue); + expect(result.target).toBe('_blank'); + expect(result.rel).toBe('noopener noreferrer'); + }); + });