@kadconsulting/dry
Version:
KAD Reusable Component Library
50 lines • 2.93 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import Icon from '../../Icon/Icon';
import { Flag04 } from './Flag04';
import { IconSizes } from '../../Icon/IconTypes';
import { render, screen } from '@testing-library/react';
describe('Flag04 icon path', () => {
it('renders with a dry-prepended className', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { size: IconSizes.SMALL, Path: Flag04 }));
// 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-flag-04')).toBeTruthy();
});
it('renders the correct defaults', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Flag04 }));
/** 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: Flag04 }));
// ASSERT
expect(screen.getByTitle('flag-04')).toBeInTheDocument();
});
it('renders with the consumer-specified stroke color', () => {
// ARRANGE
const color = 'primary';
render(_jsx(Icon, { Path: Flag04, PathProps: {
stroke: 'primary',
} }));
// ASSERT
/** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */
const pathOrGroup = screen.getByTitle('flag-04').parentElement?.children[1];
expect(pathOrGroup).toHaveAttribute('stroke', `var(--${color})`);
});
it('renders the correct path(s)', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Flag04 }));
// ASSERT
const path0 = container.firstElementChild?.children[1];
expect(path0).toHaveAttribute('d', 'M14 7h5.64c.448 0 .671 0 .802.094a.5.5 0 0 1 .205.348c.019.16-.09.356-.307.747l-1.346 2.422c-.08.142-.119.213-.134.288a.499.499 0 0 0 0 .202c.015.075.055.146.134.287l1.346 2.424c.217.39.326.586.307.746a.5.5 0 0 1-.205.348c-.13.094-.354.094-.802.094H12.6c-.56 0-.84 0-1.054-.109a1 1 0 0 1-.437-.437C11 14.24 11 13.96 11 13.4V11M4 21V4m0 7h8.4c.56 0 .84 0 1.054-.109a1 1 0 0 0 .437-.437C14 10.24 14 9.96 14 9.4V4.6c0-.56 0-.84-.109-1.054a1 1 0 0 0-.437-.437C13.24 3 12.96 3 12.4 3H5.6c-.56 0-.84 0-1.054.109a1 1 0 0 0-.437.437C4 3.76 4 4.04 4 4.6V11Z');
});
});
//# sourceMappingURL=Flag04.test.js.map