@amsterdam/design-system-react
Version:
All React components from the Amsterdam Design System. Use it to compose pages in your website or application.
37 lines (36 loc) • 1.73 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 { Table } from './Table';
import { TableBody } from './TableBody';
import { TableCell } from './TableCell';
import { TableRow } from './TableRow';
import '@testing-library/jest-dom';
describe('Table cell', () => {
it('renders', () => {
render(_jsx(Table, { children: _jsx(TableBody, { children: _jsx(TableRow, { children: _jsx(TableCell, { children: "Data" }) }) }) }));
const component = screen.getByRole('cell');
expect(component).toBeInTheDocument();
expect(component).toBeVisible();
});
it('renders a design system BEM class name', () => {
render(_jsx(Table, { children: _jsx(TableBody, { children: _jsx(TableRow, { children: _jsx(TableCell, { children: "Data" }) }) }) }));
const component = screen.getByRole('cell');
expect(component).toHaveClass('ams-table__cell');
});
it('renders an extra class name', () => {
render(_jsx(Table, { children: _jsx(TableBody, { children: _jsx(TableRow, { children: _jsx(TableCell, { className: "extra", children: "Data" }) }) }) }));
const component = screen.getByRole('cell');
expect(component).toHaveClass('ams-table__cell extra');
});
it('supports ForwardRef in React', () => {
const ref = createRef();
render(_jsx(Table, { children: _jsx(TableBody, { children: _jsx(TableRow, { children: _jsx(TableCell, { ref: ref, children: "Data" }) }) }) }));
const component = screen.getByRole('cell');
expect(ref.current).toBe(component);
});
});