UNPKG

@amsterdam/design-system-react

Version:

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

45 lines (44 loc) 1.93 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 { StandaloneLink } from './StandaloneLink'; import '@testing-library/jest-dom'; 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 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); }); });