UNPKG

@kadconsulting/dry

Version:
52 lines 2.78 kB
import { jsx as _jsx } from "react/jsx-runtime"; import Icon from '../../Icon/Icon'; import { Palette } from './Palette'; import { IconSizes } from '../../Icon/IconTypes'; import { render, screen } from '@testing-library/react'; describe('Palette icon path', () => { it('renders with a dry-prepended className', () => { // ARRANGE const { container } = render(_jsx(Icon, { size: IconSizes.SMALL, Path: Palette })); // 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-palette')).toBeTruthy(); }); it('renders the correct defaults', () => { // ARRANGE const { container } = render(_jsx(Icon, { Path: Palette })); /** 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: Palette })); // ASSERT expect(screen.getByTitle('palette')).toBeInTheDocument(); }); it('renders with the consumer-specified stroke color', () => { // ARRANGE const color = 'primary'; render(_jsx(Icon, { Path: Palette, PathProps: { stroke: 'primary', } })); // ASSERT /** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */ const pathOrGroup = screen.getByTitle('palette').parentElement?.children[1]; expect(pathOrGroup).toHaveAttribute('stroke', `var(--${color})`); }); it('renders the correct path(s)', () => { // ARRANGE const { container } = render(_jsx(Icon, { Path: Palette })); // ASSERT const path0 = container.firstElementChild?.children[1]; expect(path0).toHaveAttribute('d', 'M2 12c0 5.523 4.477 10 10 10a3 3 0 0 0 3-3v-.5c0-.464 0-.697.026-.892a3 3 0 0 1 2.582-2.582c.195-.026.428-.026.892-.026h.5a3 3 0 0 0 3-3c0-5.523-4.477-10-10-10S2 6.477 2 12Z'); const path1 = container.firstElementChild?.children[2]; expect(path1).toHaveAttribute('d', 'M7 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM16 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM10 8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z'); }); }); //# sourceMappingURL=Palette.test.js.map