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.82 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { render, screen } from '@testing-library/react'; import { createRef } from 'react'; import { Spotlight, spotlightColors } from './Spotlight'; import '@testing-library/jest-dom'; describe('Spotlight', () => { it('renders', () => { const { container } = render(_jsx(Spotlight, {})); const component = container.querySelector(':only-child'); expect(component).toBeInTheDocument(); expect(component).toBeVisible(); }); it('renders a design system BEM class name', () => { const { container } = render(_jsx(Spotlight, {})); const component = container.querySelector(':only-child'); expect(component).toHaveClass('ams-spotlight'); }); it('renders an additional class name', () => { const { container } = render(_jsx(Spotlight, { className: "extra" })); const component = container.querySelector(':only-child'); expect(component).toHaveClass('extra'); expect(component).toHaveClass('ams-spotlight'); }); it('supports ForwardRef in React', () => { const ref = createRef(); const { container } = render(_jsx(Spotlight, { ref: ref })); const component = container.querySelector(':only-child'); expect(ref.current).toBe(component); }); spotlightColors.map((color) => it(`renders with ${color} color`, () => { const { container } = render(_jsx(Spotlight, { color: color })); const component = container.querySelector(':only-child'); expect(component).toHaveClass(`ams-spotlight--${color}`); })); it('renders a custom tag', () => { render(_jsx(Spotlight, { as: "article" })); const cell = screen.getByRole('article'); expect(cell).toBeInTheDocument(); }); });