@amsterdam/design-system-react
Version:
All React components from the Amsterdam Design System. Use it to compose pages in your website or application.
43 lines (42 loc) • 1.85 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { render, screen } from '@testing-library/react';
import { createRef } from 'react';
import { TopTaskLink } from './TopTaskLink';
import '@testing-library/jest-dom';
describe('Top task link', () => {
it('renders a link role element', () => {
render(_jsx(TopTaskLink, { description: "Description", href: "/", label: "Label" }));
const link = screen.getByRole('link', {
name: 'Label , Description',
});
expect(link).toBeInTheDocument();
expect(link).toBeVisible();
});
it('renders a design system BEM class name', () => {
render(_jsx(TopTaskLink, { description: "Description", href: "/", label: "Label" }));
const link = screen.getByRole('link', {
name: 'Label , Description',
});
const label = screen.getByText('Label');
const description = screen.getByText('Description');
expect(link).toHaveClass('ams-top-task-link');
expect(label).toHaveClass('ams-top-task-link__label');
expect(description).toHaveClass('ams-top-task-link__description');
});
it('renders an additional class name', () => {
render(_jsx(TopTaskLink, { className: "extra", description: "Description", href: "/", label: "Label" }));
const link = screen.getByRole('link', {
name: 'Label , Description',
});
expect(link).toHaveClass('extra');
expect(link).toHaveClass('ams-top-task-link');
});
it('supports ForwardRef in React', () => {
const ref = createRef();
render(_jsx(TopTaskLink, { description: "Description", href: "/", label: "Label", ref: ref }));
const link = screen.getByRole('link', {
name: 'Label , Description',
});
expect(ref.current).toBe(link);
});
});