UNPKG

@kadconsulting/dry

Version:
50 lines 2.87 kB
import { jsx as _jsx } from "react/jsx-runtime"; import Icon from '../../Icon/Icon'; import { Eraser } from './Eraser'; import { IconSizes } from '../../Icon/IconTypes'; import { render, screen } from '@testing-library/react'; describe('Eraser icon path', () => { it('renders with a dry-prepended className', () => { // ARRANGE const { container } = render(_jsx(Icon, { size: IconSizes.SMALL, Path: Eraser })); // ASSERT /** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */ const pathOrGroup = container.firstElementChild?.children[1]; expect(Array.from(pathOrGroup?.classList ?? []).includes('dry-icon-eraser')).toBeTruthy(); }); it('renders the correct defaults', () => { // ARRANGE const { container } = render(_jsx(Icon, { Path: Eraser })); /** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */ const pathOrGroup = container.firstElementChild?.children[1]; expect(pathOrGroup).toHaveAttribute('stroke', '#000'); expect(pathOrGroup).toHaveAttribute('stroke-width', '2'); expect(pathOrGroup).toHaveAttribute('stroke-linecap', 'round'); expect(pathOrGroup).toHaveAttribute('stroke-linejoin', 'round'); }); it('renders the correct accessibility title', () => { // ARRANGE render(_jsx(Icon, { Path: Eraser })); // ASSERT expect(screen.getByTitle('eraser')).toBeInTheDocument(); }); it('renders with the consumer-specified stroke color', () => { // ARRANGE const color = 'primary'; render(_jsx(Icon, { Path: Eraser, PathProps: { stroke: 'primary', } })); // ASSERT /** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */ const pathOrGroup = screen.getByTitle('eraser').parentElement?.children[1]; expect(pathOrGroup).toHaveAttribute('stroke', `var(--${color})`); }); it('renders the correct path(s)', () => { // ARRANGE const { container } = render(_jsx(Icon, { Path: Eraser })); // ASSERT const path0 = container.firstElementChild?.children[1]; expect(path0).toHaveAttribute('d', 'm18 13-7-7m10 15H8m2.937-.937 8.668-8.669c1.189-1.188 1.782-1.782 2.005-2.467a3.001 3.001 0 0 0 0-1.854c-.223-.685-.816-1.279-2.005-2.467l-.211-.212c-1.188-1.188-1.782-1.782-2.467-2.004a3 3 0 0 0-1.854 0c-.686.222-1.28.816-2.468 2.004l-8.211 8.212c-1.188 1.188-1.782 1.782-2.005 2.467a3 3 0 0 0 0 1.854c.223.685.817 1.28 2.005 2.467l.668.669c.346.346.52.519.721.642.179.11.374.19.578.24.23.055.475.055.964.055h1.35c.488 0 .733 0 .963-.055.204-.05.4-.13.578-.24.202-.123.375-.296.72-.642Z'); }); }); //# sourceMappingURL=Eraser.test.js.map