UNPKG

@kadconsulting/dry

Version:
50 lines 3.41 kB
import { jsx as _jsx } from "react/jsx-runtime"; import Icon from '../../Icon/Icon'; import { Star02 } from './Star02'; import { IconSizes } from '../../Icon/IconTypes'; import { render, screen } from '@testing-library/react'; describe('Star02 icon path', () => { it('renders with a dry-prepended className', () => { // ARRANGE const { container } = render(_jsx(Icon, { size: IconSizes.SMALL, Path: Star02 })); // 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-star-02')).toBeTruthy(); }); it('renders the correct defaults', () => { // ARRANGE const { container } = render(_jsx(Icon, { Path: Star02 })); /** 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: Star02 })); // ASSERT expect(screen.getByTitle('star-02')).toBeInTheDocument(); }); it('renders with the consumer-specified stroke color', () => { // ARRANGE const color = 'primary'; render(_jsx(Icon, { Path: Star02, PathProps: { stroke: 'primary', } })); // ASSERT /** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */ const pathOrGroup = screen.getByTitle('star-02').parentElement?.children[1]; expect(pathOrGroup).toHaveAttribute('stroke', `var(--${color})`); }); it('renders the correct path(s)', () => { // ARRANGE const { container } = render(_jsx(Icon, { Path: Star02 })); // ASSERT const path0 = container.firstElementChild?.children[1]; expect(path0).toHaveAttribute('d', 'M11.306 3.207c.228-.396.342-.594.49-.66a.5.5 0 0 1 .408 0c.148.066.262.264.49.66l1.955 3.402c.084.147.126.22.185.273a.5.5 0 0 0 .18.105c.077.024.161.024.33.024l3.924-.008c.457-.001.685-.002.817.094a.5.5 0 0 1 .203.353c.017.162-.097.36-.326.754l-1.97 3.394c-.084.147-.126.22-.143.297a.5.5 0 0 0 0 .21c.017.077.059.15.144.296l1.969 3.395c.229.395.343.592.326.754a.5.5 0 0 1-.203.353c-.132.096-.36.095-.817.094l-3.924-.008c-.169 0-.253 0-.33.024a.5.5 0 0 0-.18.104c-.059.054-.101.127-.185.273l-1.955 3.403c-.228.396-.342.594-.49.66a.5.5 0 0 1-.408 0c-.148-.066-.262-.264-.49-.66L9.351 17.39c-.084-.147-.126-.22-.185-.273a.5.5 0 0 0-.18-.105c-.077-.024-.161-.024-.33-.024l-3.924.008c-.457.001-.685.002-.817-.094a.5.5 0 0 1-.204-.353c-.016-.162.098-.36.327-.754l1.97-3.395c.084-.146.126-.219.143-.297a.5.5 0 0 0 0-.208c-.017-.078-.06-.151-.144-.298L4.038 8.204c-.229-.395-.343-.592-.327-.754a.5.5 0 0 1 .204-.353c.132-.096.36-.095.817-.094l3.924.008c.169 0 .253 0 .33-.024a.5.5 0 0 0 .18-.105c.059-.053.1-.126.185-.273l1.955-3.402Z'); }); }); //# sourceMappingURL=Star02.test.js.map