@kadconsulting/dry
Version:
KAD Reusable Component Library
54 lines • 3.3 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import Icon from '../../Icon/Icon';
import { MessageHeartCircle } from './MessageHeartCircle';
import { IconSizes } from '../../Icon/IconTypes';
import { render, screen } from '@testing-library/react';
describe('MessageHeartCircle icon path', () => {
it('renders with a dry-prepended className', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { size: IconSizes.SMALL, Path: MessageHeartCircle }));
// 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-message-heart-circle')).toBeTruthy();
});
it('renders the correct defaults', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: MessageHeartCircle }));
/** 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: MessageHeartCircle }));
// ASSERT
expect(screen.getByTitle('message-heart-circle')).toBeInTheDocument();
});
it('renders with the consumer-specified stroke color', () => {
// ARRANGE
const color = 'primary';
render(_jsx(Icon, { Path: MessageHeartCircle, PathProps: {
stroke: 'primary',
} }));
// ASSERT
/** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */
const pathOrGroup = screen.getByTitle('message-heart-circle').parentElement
?.children[1];
expect(pathOrGroup).toHaveAttribute('stroke', `var(--${color})`);
});
it('renders the correct path(s)', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: MessageHeartCircle }));
// ASSERT
const path0 = container.firstElementChild?.children[1];
expect(path0).toHaveAttribute('d', 'M21 11.5a8.5 8.5 0 0 1-11.555 7.934c-.174-.066-.26-.1-.33-.116a.901.901 0 0 0-.186-.024 2.314 2.314 0 0 0-.303.021l-5.12.53c-.49.05-.733.075-.877-.013a.5.5 0 0 1-.234-.35c-.026-.166.09-.382.324-.814l1.636-3.027c.134-.25.202-.374.232-.494a.899.899 0 0 0 .028-.326c-.01-.123-.064-.283-.172-.604A8.5 8.5 0 1 1 21 11.5Z');
const path1 = container.firstElementChild?.children[2];
expect(path1).toHaveAttribute('d', 'M12.496 8.95c-.9-1.04-2.4-1.319-3.527-.368-1.127.951-1.286 2.542-.4 3.667.548.697 1.924 1.97 2.893 2.838.355.319.533.478.746.542.183.055.394.055.577 0 .213-.064.39-.223.746-.542.969-.868 2.345-2.14 2.894-2.838a2.606 2.606 0 0 0-.401-3.667c-1.147-.941-2.628-.672-3.528.367Z');
expect(path1).toHaveAttribute('clip-rule', 'evenodd');
});
});
//# sourceMappingURL=MessageHeartCircle.test.js.map