@amsterdam/design-system-react
Version:
All React components from the Amsterdam Design System. Use it to compose pages in your website or application.
71 lines (70 loc) • 3.5 kB
JavaScript
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 { ProgressList } from './ProgressList';
describe('ProgressListSubstep', () => {
it('renders', () => {
render(_jsx(ProgressList.Substep, { children: "Content" }));
const substep = screen.getByRole('listitem');
expect(substep).toBeInTheDocument();
expect(substep).toBeVisible();
});
it('renders a design system BEM class name', () => {
render(_jsx(ProgressList.Substep, { children: "Content" }));
const substep = screen.getByRole('listitem');
expect(substep).toHaveClass('ams-progress-list-substeps__step');
});
it('renders the marker', () => {
const { container } = render(_jsx(ProgressList.Substep, { children: "Content" }));
const marker = container.querySelector('.ams-progress-list-substeps__marker');
expect(marker).toBeInTheDocument();
});
it('renders the connector', () => {
const { container } = render(_jsx(ProgressList.Substep, { children: "Content" }));
const connector = container.querySelector('.ams-progress-list-substeps__connector');
expect(connector).toBeInTheDocument();
});
it('renders an extra class name', () => {
render(_jsx(ProgressList.Substep, { className: "extra", children: "Content" }));
const substep = screen.getByRole('listitem');
expect(substep).toHaveClass('ams-progress-list-substeps__step extra');
});
it('renders the current status class name', () => {
render(_jsx(ProgressList.Substep, { status: "current", children: "Content" }));
const substep = screen.getByRole('listitem');
expect(substep).toHaveClass('ams-progress-list-substeps__step--current');
});
it('renders the completed status class name', () => {
render(_jsx(ProgressList.Substep, { status: "completed", children: "Content" }));
const substep = screen.getByRole('listitem');
expect(substep).toHaveClass('ams-progress-list-substeps__step--completed');
});
it('renders aria-current attribute when status is current', () => {
render(_jsx(ProgressList.Substep, { status: "current", children: "Content" }));
const substep = screen.getByRole('listitem');
expect(substep).toHaveAttribute('aria-current', 'step');
});
it('does not render aria-current attribute when status is completed', () => {
render(_jsx(ProgressList.Substep, { status: "completed", children: "Content" }));
const substep = screen.getByRole('listitem');
expect(substep).not.toHaveAttribute('aria-current');
});
it('supports ForwardRef in React', () => {
const ref = createRef();
render(_jsx(ProgressList.Substep, { ref: ref, children: "Content" }));
const substep = screen.getByRole('listitem');
expect(ref.current).toBe(substep);
});
it('passes additional props', () => {
render(_jsx(ProgressList.Substep, { "aria-hidden": "false", "data-test": "data-test", id: "id" }));
const component = screen.getByRole('listitem');
expect(component).toHaveAttribute('aria-hidden', 'false');
expect(component).toHaveAttribute('id', 'id');
expect(component).toHaveAttribute('data-test', 'data-test');
});
});