import { render, screen } from '@testing-library/react'; import type { ReactNode } from 'react'; import { describe, expect, test, vi } from 'vitest'; import { InlineLink } from './inline-link'; vi.mock('next/link', () => ({ default: ({ href, children, ...props }: { href: string; children: ReactNode; }) => ( {children} ), })); describe('InlineLink', () => { test('renders as a normal link by default', () => { render(Posts); const link = screen.getByRole('link', { name: 'Posts' }); expect(link).toHaveAttribute('href', '/posts'); expect(link).not.toHaveAttribute('target', '_blank'); }); test('sets target blank when blank prop is true', () => { render( External , ); const link = screen.getByRole('link', { name: 'External' }); expect(link).toHaveAttribute('href', 'https://example.com'); expect(link).toHaveAttribute('target', '_blank'); }); });