UNPKG

@amsterdam/design-system-react

Version:

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

41 lines (40 loc) 1.76 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 { describe, expect, it } from 'vitest'; import { CallToActionLink } from './CallToActionLink'; describe('CallToActionLink', () => { it('renders with href attribute', () => { render(_jsx(CallToActionLink, { href: "#" })); const component = screen.getByRole('link'); expect(component).toBeInTheDocument(); expect(component).toHaveAttribute('href', '#'); }); it('renders a design system BEM class name', () => { render(_jsx(CallToActionLink, { href: "#" })); const component = screen.getByRole('link'); expect(component).toHaveClass('ams-call-to-action-link'); }); it('renders an extra class name', () => { render(_jsx(CallToActionLink, { className: "extra", href: "#" })); const component = screen.getByRole('link'); expect(component).toHaveClass('ams-call-to-action-link extra'); }); it('supports ForwardRef in React', () => { const ref = createRef(); render(_jsx(CallToActionLink, { href: "#", ref: ref })); const component = screen.getByRole('link'); expect(ref.current).toBe(component); }); it('passes additional props', () => { render(_jsx(CallToActionLink, { "aria-hidden": false, "data-test": "data-test", href: "#", id: "id" })); const component = screen.getByRole('link'); expect(component).toHaveAttribute('aria-hidden', 'false'); expect(component).toHaveAttribute('id', 'id'); expect(component).toHaveAttribute('data-test', 'data-test'); }); });