UNPKG

@amsterdam/design-system-react

Version:

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

44 lines (43 loc) 1.73 kB
import { jsx as _jsx } from "react/jsx-runtime"; /** * @license EUPL-1.2+ * Copyright Gemeente Amsterdam */ import { render, screen } from '@testing-library/react'; import { createRef } from 'react'; import { Link } from './Link'; import '@testing-library/jest-dom'; describe('Link', () => { it('renders with href attribute', () => { render(_jsx(Link, { href: "#" })); const component = screen.getByRole('link'); expect(component).toBeInTheDocument(); expect(component).toHaveAttribute('href', '#'); }); it('renders a design system BEM class name', () => { render(_jsx(Link, { href: "#" })); const component = screen.getByRole('link'); expect(component).toHaveClass('ams-link'); }); it('renders an extra class name', () => { render(_jsx(Link, { className: "extra", href: "#" })); const component = screen.getByRole('link'); expect(component).toHaveClass('ams-link extra'); }); it('renders the class name for contrast color', () => { render(_jsx(Link, { color: "contrast", href: "#" })); const component = screen.getByRole('link'); expect(component).toHaveClass('ams-link ams-link--contrast'); }); it('renders the class name for inverse color', () => { render(_jsx(Link, { color: "inverse", href: "#" })); const component = screen.getByRole('link'); expect(component).toHaveClass('ams-link ams-link--inverse'); }); it('supports ForwardRef in React', () => { const ref = createRef(); render(_jsx(Link, { href: "#", ref: ref })); const component = screen.getByRole('link'); expect(ref.current).toBe(component); }); });