UNPKG

@amsterdam/design-system-react

Version:

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

49 lines (48 loc) 2.04 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 { IconButton } from './IconButton'; import '@testing-library/jest-dom'; describe('Icon button', () => { it('renders', () => { render(_jsx(IconButton, { label: "Test" })); const component = screen.getByRole('button'); expect(component).toBeInTheDocument(); expect(component).toBeVisible(); }); it('renders a design system BEM class name', () => { render(_jsx(IconButton, { label: "Test" })); const component = screen.getByRole('button'); expect(component).toHaveClass('ams-icon-button'); }); it('renders an extra class name', () => { render(_jsx(IconButton, { className: "extra", label: "Test" })); const component = screen.getByRole('button'); expect(component).toHaveClass('ams-icon-button extra'); }); it('renders an accessible label', () => { render(_jsx(IconButton, { className: "extra", label: "Test" })); const component = screen.getByRole('button', { name: 'Test' }); expect(component).toBeInTheDocument(); }); it('renders the class name for contrast color', () => { render(_jsx(IconButton, { color: "contrast", label: "Test" })); const component = screen.getByRole('button'); expect(component).toHaveClass('ams-icon-button--contrast'); }); it('renders the class name for inverse color', () => { render(_jsx(IconButton, { color: "inverse", label: "Test" })); const component = screen.getByRole('button'); expect(component).toHaveClass('ams-icon-button--inverse'); }); it('supports ForwardRef in React', () => { const ref = createRef(); render(_jsx(IconButton, { label: "Test", ref: ref })); const component = screen.getByRole('button'); expect(ref.current).toBe(component); }); });