UNPKG

@amsterdam/design-system-react

Version:

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

55 lines (54 loc) 2.4 kB
import { jsx as _jsx } from "react/jsx-runtime"; /** * @license EUPL-1.2+ * Copyright Gemeente Amsterdam */ import '@testing-library/jest-dom'; import { render, screen } from '@testing-library/react'; import { createRef } from 'react'; import { LinkList } from './LinkList'; describe('Link list link', () => { it('renders', () => { const { container } = render(_jsx(LinkList.Link, { href: "#" })); const listItem = screen.getByRole('listitem'); const link = screen.getByRole('link'); const icon = container.querySelector('svg'); expect(listItem).toBeInTheDocument(); expect(listItem).toBeVisible(); expect(link).toBeInTheDocument(); expect(link).toBeVisible(); expect(icon).toBeInTheDocument(); expect(icon).not.toBeVisible(); // The icon is hidden by default, and only shown when the CSS loads. }); it('renders a design system BEM class name', () => { render(_jsx(LinkList.Link, { href: "#" })); const component = screen.getByRole('link'); expect(component).toHaveClass('ams-link-list__link'); }); it('renders an extra class name', () => { render(_jsx(LinkList.Link, { className: "extra", href: "#" })); const component = screen.getByRole('link'); expect(component).toHaveClass('ams-link-list__link extra'); }); it('renders a class name for the small size', () => { render(_jsx(LinkList.Link, { href: "#", size: "small" })); const component = screen.getByRole('link'); expect(component).toHaveClass('ams-link-list__link--small'); }); it('renders the class name for contrast color', () => { render(_jsx(LinkList.Link, { color: "contrast", href: "#" })); const component = screen.getByRole('link'); expect(component).toHaveClass('ams-link-list__link--contrast'); }); it('renders the class name for inverse color', () => { render(_jsx(LinkList.Link, { color: "inverse", href: "#" })); const component = screen.getByRole('link'); expect(component).toHaveClass('ams-link-list__link--inverse'); }); it('supports ForwardRef in React', () => { const ref = createRef(); render(_jsx(LinkList.Link, { href: "#", ref: ref })); const component = screen.getByRole('link'); expect(ref.current).toBe(component); }); });