UNPKG

@amsterdam/design-system-react

Version:

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

44 lines (43 loc) 2.06 kB
import { jsx as _jsx } from "react/jsx-runtime"; /** * @license EUPL-1.2+ * Copyright Gemeente Amsterdam */ import { render } from '@testing-library/react'; import { createRef } from 'react'; import { DescriptionList, descriptionListTermsWidths } from './DescriptionList'; import '@testing-library/jest-dom'; describe('Description List', () => { it('renders', () => { const { container } = render(_jsx(DescriptionList, {})); const component = container.querySelector(':only-child'); expect(component).toBeInTheDocument(); expect(component).toBeVisible(); }); it('renders a design system BEM class name', () => { const { container } = render(_jsx(DescriptionList, {})); const component = container.querySelector(':only-child'); expect(component).toHaveClass('ams-description-list'); }); it('renders an extra class name', () => { const { container } = render(_jsx(DescriptionList, { className: "extra" })); const component = container.querySelector(':only-child'); expect(component).toHaveClass('ams-description-list extra'); }); descriptionListTermsWidths.map((width) => it(`renders the class name for the ‘${width}’ terms column width`, () => { const { container } = render(_jsx(DescriptionList, { termsWidth: width })); const component = container.querySelector(':only-child'); expect(component).toHaveClass(`ams-description-list--${width}`); })); it('supports ForwardRef in React', () => { const ref = createRef(); const { container } = render(_jsx(DescriptionList, { ref: ref })); const component = container.querySelector(':only-child'); expect(ref.current).toBe(component); }); it('renders the class name for inverse color', () => { const { container } = render(_jsx(DescriptionList, { color: "inverse" })); const component = container.querySelector(':only-child'); expect(component).toHaveClass('ams-description-list--inverse'); }); });