@kadconsulting/dry
Version:
KAD Reusable Component Library
50 lines • 3.14 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import Icon from '../../Icon/Icon';
import { Award03 } from './Award03';
import { IconSizes } from '../../Icon/IconTypes';
import { render, screen } from '@testing-library/react';
describe('Award03 icon path', () => {
it('renders with a dry-prepended className', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { size: IconSizes.SMALL, Path: Award03 }));
// 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-award-03')).toBeTruthy();
});
it('renders the correct defaults', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Award03 }));
/** 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: Award03 }));
// ASSERT
expect(screen.getByTitle('award-03')).toBeInTheDocument();
});
it('renders with the consumer-specified stroke color', () => {
// ARRANGE
const color = 'primary';
render(_jsx(Icon, { Path: Award03, PathProps: {
stroke: 'primary',
} }));
// ASSERT
/** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */
const pathOrGroup = screen.getByTitle('award-03').parentElement?.children[1];
expect(pathOrGroup).toHaveAttribute('stroke', `var(--${color})`);
});
it('renders the correct path(s)', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Award03 }));
// ASSERT
const path0 = container.firstElementChild?.children[1];
expect(path0).toHaveAttribute('d', 'M7.869 15.46 7 22l4.588-2.753c.15-.09.225-.135.305-.152a.5.5 0 0 1 .214 0c.08.017.155.062.305.152L17 22l-.868-6.543m.294-11.208c.154.373.45.67.824.825l1.309.542a1.525 1.525 0 0 1 .825 1.992l-.542 1.308a1.522 1.522 0 0 0 0 1.168l.542 1.307a1.525 1.525 0 0 1-.826 1.993l-1.308.542c-.373.154-.67.45-.825.824l-.542 1.309a1.524 1.524 0 0 1-1.992.825l-1.308-.542a1.525 1.525 0 0 0-1.166 0l-1.31.542a1.524 1.524 0 0 1-1.99-.824l-.542-1.31a1.524 1.524 0 0 0-.824-.825l-1.31-.542a1.524 1.524 0 0 1-.825-1.991l.542-1.308a1.525 1.525 0 0 0 0-1.167l-.542-1.31a1.525 1.525 0 0 1 .826-1.992l1.307-.542c.374-.154.67-.45.825-.823l.543-1.309a1.524 1.524 0 0 1 1.991-.825l1.308.542c.374.154.793.154 1.167-.001l1.31-.54a1.525 1.525 0 0 1 1.99.825l.543 1.31v-.003Z');
});
});
//# sourceMappingURL=Award03.test.js.map