UNPKG

@amsterdam/design-system-react

Version:

All React components from the Amsterdam Design System. Use it to compose pages in your website or application.

47 lines (46 loc) 2.17 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { render, screen } from '@testing-library/react'; import { createRef } from 'react'; import { StandaloneLink } from './StandaloneLink'; import '@testing-library/jest-dom'; const TestIcon = (props) => _jsx("svg", { ...props, className: "test-class" }); describe('Standalone Link', () => { it('renders with href attribute', () => { render(_jsx(StandaloneLink, { href: "#" })); const component = screen.getByRole('link'); expect(component).toBeInTheDocument(); expect(component).toBeVisible(); expect(component).toHaveAttribute('href', '#'); }); it('renders a design system BEM class name', () => { render(_jsx(StandaloneLink, { href: "#" })); const component = screen.getByRole('link'); expect(component).toHaveClass('ams-standalone-link'); }); it('renders an extra class name', () => { render(_jsx(StandaloneLink, { className: "extra", href: "#" })); const component = screen.getByRole('link'); expect(component).toHaveClass('ams-standalone-link extra'); }); it('renders a custom icon', () => { const { container } = render(_jsx(StandaloneLink, { icon: TestIcon })); const icon = container.querySelector('svg'); expect(icon).toHaveClass('test-class'); }); it('renders the class name for contrast color', () => { render(_jsx(StandaloneLink, { color: "contrast", href: "#" })); const component = screen.getByRole('link'); expect(component).toHaveClass('ams-standalone-link ams-standalone-link--contrast'); }); it('renders the class name for inverse color', () => { render(_jsx(StandaloneLink, { color: "inverse", href: "#" })); const component = screen.getByRole('link'); expect(component).toHaveClass('ams-standalone-link ams-standalone-link--inverse'); }); it('supports ForwardRef in React', () => { const ref = createRef(); render(_jsx(StandaloneLink, { href: "#", ref: ref })); const component = screen.getByRole('link'); expect(ref.current).toBe(component); }); });