Skip to content

Commit c6ef2f1

Browse files
roottdonohue
authored andcommitted
Addition of unit tests for the getLinkAttributes() method
1 parent 2a1ef02 commit c6ef2f1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/app/item-page/field-components/metadata-values/metadata-values.component.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,20 @@ describe('MetadataValuesComponent', () => {
7373
expect(comp.hasLink(mdValue)).toBe(true);
7474
});
7575

76+
it('should return correct target and rel for internal links', () => {
77+
spyOn(comp, 'hasInternalLink').and.returnValue(true);
78+
const urlValue = '/internal-link';
79+
const result = comp.getLinkAttributes(urlValue);
80+
expect(result.target).toBe('_self');
81+
expect(result.rel).toBe('');
82+
});
83+
84+
it('should return correct target and rel for external links', () => {
85+
spyOn(comp, 'hasInternalLink').and.returnValue(false);
86+
const urlValue = 'https://www.dspace.org';
87+
const result = comp.getLinkAttributes(urlValue);
88+
expect(result.target).toBe('_blank');
89+
expect(result.rel).toBe('noopener noreferrer');
90+
});
91+
7692
});

0 commit comments

Comments
 (0)