UNPKG

@kadconsulting/dry

Version:
50 lines 3.16 kB
import { jsx as _jsx } from "react/jsx-runtime"; import Icon from '../../Icon/Icon'; import { Codepen } from './Codepen'; import { IconSizes } from '../../Icon/IconTypes'; import { render, screen } from '@testing-library/react'; describe('Codepen icon path', () => { it('renders with a dry-prepended className', () => { // ARRANGE const { container } = render(_jsx(Icon, { size: IconSizes.SMALL, Path: Codepen })); // 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-codepen')).toBeTruthy(); }); it('renders the correct defaults', () => { // ARRANGE const { container } = render(_jsx(Icon, { Path: Codepen })); /** 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: Codepen })); // ASSERT expect(screen.getByTitle('codepen')).toBeInTheDocument(); }); it('renders with the consumer-specified stroke color', () => { // ARRANGE const color = 'primary'; render(_jsx(Icon, { Path: Codepen, PathProps: { stroke: 'primary', } })); // ASSERT /** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */ const pathOrGroup = screen.getByTitle('codepen').parentElement?.children[1]; expect(pathOrGroup).toHaveAttribute('stroke', `var(--${color})`); }); it('renders the correct path(s)', () => { // ARRANGE const { container } = render(_jsx(Icon, { Path: Codepen })); // ASSERT const path0 = container.firstElementChild?.children[1]; expect(path0).toHaveAttribute('d', 'M12 9 4.064 14.16c-.688.447-1.032.67-1.151.954a1 1 0 0 0 0 .774M12 9l7.936 5.159c.688.447 1.032.67 1.151.954a1 1 0 0 1 0 .774M12 9V2.5M12 15 4.064 9.842c-.688-.447-1.032-.671-1.151-.954a1 1 0 0 1 0-.775M12 15l7.936-5.158c.688-.447 1.032-.671 1.151-.954a1 1 0 0 0 0-.775M12 15v6.5m9.272-5.527-8.4 5.46c-.316.206-.473.308-.643.348a1 1 0 0 1-.457 0c-.17-.04-.328-.142-.644-.348l-8.4-5.46c-.266-.173-.399-.259-.495-.374a1 1 0 0 1-.189-.348C2 15.108 2 14.95 2 14.631V9.369c0-.317 0-.475.044-.619a1 1 0 0 1 .189-.347c.096-.116.229-.202.495-.375l8.4-5.46c.316-.205.473-.308.643-.348a1 1 0 0 1 .457 0c.17.04.328.143.644.348l8.4 5.46c.266.173.399.26.495.375a1 1 0 0 1 .189.347c.044.144.044.302.044.62v5.263c0 .317 0 .476-.044.62a1 1 0 0 1-.189.347c-.096.115-.229.201-.495.374Z'); }); }); //# sourceMappingURL=Codepen.test.js.map