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
7 changes: 4 additions & 3 deletions packages/pxweb2-ui/src/lib/components/Link/Link.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom/vitest';

import Link from './Link';

Expand All @@ -13,11 +14,11 @@ describe('Link', () => {
expect(link.getAttribute('href')).toBe('#');
});

it('sets empty target attribute when target prop is not provided', () => {
it('omits target attribute when target prop is not provided', () => {
render(<Link href="#">{linkText}</Link>);
const link = screen.getByRole('link');
// target="" is explicitly set in component when no target passed
expect(link.getAttribute('target')).toBe('');
expect(link).not.toHaveAttribute('target');
expect(link.getAttribute('target')).toBeNull();
});

it('applies target attribute when provided', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/pxweb2-ui/src/lib/components/Link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
return (
<a
href={href}
target={target ? target : ''}
target={target}
className={cl(classes.link, {
[classes.no_underline]: noUnderline,
[classes.inline]: inline,
Expand Down
Loading