Skip to content

Commit

Permalink
Addition of unit tests for the getLinkAttributes() method
Browse files Browse the repository at this point in the history
(cherry picked from commit 8572bfb)
  • Loading branch information
root authored and github-actions[bot] committed Dec 19, 2024
1 parent f8431db commit 8a778f6
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,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');
});

});

0 comments on commit 8a778f6

Please sign in to comment.