mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Addition of unit tests for the getLinkAttributes() method
(cherry picked from commit 8572bfb1b1
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
f8431dbdd7
commit
8a778f6c3d
@@ -83,4 +83,20 @@ describe('MetadataValuesComponent', () => {
|
|||||||
expect(comp.hasLink(mdValue)).toBe(true);
|
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');
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user