Skip to content

Commit 8a778f6

Browse files
rootgithub-actions[bot]
authored andcommitted
Addition of unit tests for the getLinkAttributes() method
(cherry picked from commit 8572bfb)
1 parent f8431db commit 8a778f6

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
@@ -83,4 +83,20 @@ describe('MetadataValuesComponent', () => {
8383
expect(comp.hasLink(mdValue)).toBe(true);
8484
});
8585

86+
it('should return correct target and rel for internal links', () => {
87+
spyOn(comp, 'hasInternalLink').and.returnValue(true);
88+
const urlValue = '/internal-link';
89+
const result = comp.getLinkAttributes(urlValue);
90+
expect(result.target).toBe('_self');
91+
expect(result.rel).toBe('');
92+
});
93+
94+
it('should return correct target and rel for external links', () => {
95+
spyOn(comp, 'hasInternalLink').and.returnValue(false);
96+
const urlValue = 'https://www.dspace.org';
97+
const result = comp.getLinkAttributes(urlValue);
98+
expect(result.target).toBe('_blank');
99+
expect(result.rel).toBe('noopener noreferrer');
100+
});
101+
86102
});

0 commit comments

Comments
 (0)