UNPKG

@kadconsulting/dry

Version:
50 lines 2.87 kB
import { jsx as _jsx } from "react/jsx-runtime"; import Icon from '../../Icon/Icon'; import { Shield02 } from './Shield02'; import { IconSizes } from '../../Icon/IconTypes'; import { render, screen } from '@testing-library/react'; describe('Shield02 icon path', () => { it('renders with a dry-prepended className', () => { // ARRANGE const { container } = render(_jsx(Icon, { size: IconSizes.SMALL, Path: Shield02 })); // 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-shield-02')).toBeTruthy(); }); it('renders the correct defaults', () => { // ARRANGE const { container } = render(_jsx(Icon, { Path: Shield02 })); /** 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: Shield02 })); // ASSERT expect(screen.getByTitle('shield-02')).toBeInTheDocument(); }); it('renders with the consumer-specified stroke color', () => { // ARRANGE const color = 'primary'; render(_jsx(Icon, { Path: Shield02, PathProps: { stroke: 'primary', } })); // ASSERT /** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */ const pathOrGroup = screen.getByTitle('shield-02').parentElement?.children[1]; expect(pathOrGroup).toHaveAttribute('stroke', `var(--${color})`); }); it('renders the correct path(s)', () => { // ARRANGE const { container } = render(_jsx(Icon, { Path: Shield02 })); // ASSERT const path0 = container.firstElementChild?.children[1]; expect(path0).toHaveAttribute('d', 'M11.302 21.615c.221.13.332.194.488.227.122.026.298.026.42 0 .156-.033.267-.098.488-.227C14.646 20.479 20 16.909 20 12V8.2c0-1.074 0-1.61-.166-1.992a1.746 1.746 0 0 0-.68-.837c-.34-.24-1.005-.378-2.336-.655-1.467-.305-2.594-.856-3.624-1.653-.494-.382-.74-.573-.934-.625a.842.842 0 0 0-.52 0c-.194.052-.44.243-.934.625-1.03.797-2.157 1.348-3.624 1.653-1.33.277-1.996.415-2.336.655-.345.244-.512.45-.68.837C4 6.59 4 7.126 4 8.2V12c0 4.909 5.354 8.479 7.302 9.615Z'); }); }); //# sourceMappingURL=Shield02.test.js.map