Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const detailsSectionNo = {
items: [
{ text: 'Endringer i tabeller', url: '#' },
{ text: 'Kom i gang', url: '#' },
{ text: 'Target type blank', url: '#', openInNewTab: true },
{ text: 'Target type self', url: '#', openInNewTab: false },
],
},
},
Expand Down Expand Up @@ -49,6 +51,21 @@ describe('StartPageDetails (renders from props)', () => {
expect(
screen.getByRole('link', { name: 'Endringer i tabeller' }),
).toBeInTheDocument();

const linkWithoutOpenInNewTab = screen.getByRole('link', {
name: 'Kom i gang',
});
expect(linkWithoutOpenInNewTab).toHaveAttribute('target', '_self');

const linkWithTargetBlank = screen.getByRole('link', {
name: 'Target type blank',
});
expect(linkWithTargetBlank).toHaveAttribute('target', '_blank');

const linkWithTargetSelf = screen.getByRole('link', {
name: 'Target type self',
});
expect(linkWithTargetSelf).toHaveAttribute('target', '_self');
});

it('renders nothing when enabled=false', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const renderLinksList = (items?: DetailLink[]) => {
<Link
href={link.url}
size="medium"
target={link.openInNewTab ? '_blank' : '_self'}
{...(link.icon
? { icon: link.icon, iconPosition: link.iconPosition ?? 'left' }
: {})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type DetailLink = {
url: string;
icon?: IconProps['iconName'];
iconPosition?: 'left' | 'right';
openInNewTab?: boolean;
};

export type Links = {
Expand Down