Skip to content

Commit

Permalink
Addition of unit tests for the getLinkAttributes() method
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and tdonohue committed Dec 19, 2024
1 parent 2a1ef02 commit c6ef2f1
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

});

0 comments on commit c6ef2f1

Please sign in to comment.