@kadconsulting/dry
Version:
KAD Reusable Component Library
50 lines • 2.69 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import Icon from '../../Icon/Icon';
import { Podcast } from './Podcast';
import { IconSizes } from '../../Icon/IconTypes';
import { render, screen } from '@testing-library/react';
describe('Podcast icon path', () => {
it('renders with a dry-prepended className', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { size: IconSizes.SMALL, Path: Podcast }));
// 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-podcast')).toBeTruthy();
});
it('renders the correct defaults', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Podcast }));
/** 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: Podcast }));
// ASSERT
expect(screen.getByTitle('podcast')).toBeInTheDocument();
});
it('renders with the consumer-specified stroke color', () => {
// ARRANGE
const color = 'primary';
render(_jsx(Icon, { Path: Podcast, PathProps: {
stroke: 'primary',
} }));
// ASSERT
/** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */
const pathOrGroup = screen.getByTitle('podcast').parentElement?.children[1];
expect(pathOrGroup).toHaveAttribute('stroke', `var(--${color})`);
});
it('renders the correct path(s)', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Podcast }));
// ASSERT
const path0 = container.firstElementChild?.children[1];
expect(path0).toHaveAttribute('d', 'M17.119 18C19.462 16.415 21 13.778 21 10.785 21 5.933 16.97 2 12 2s-9 3.933-9 8.785c0 2.993 1.538 5.63 3.881 7.215m1.479-4C7.519 13.15 7 12.009 7 10.75 7 8.128 9.239 6 12 6s5 2.127 5 4.75c0 1.26-.519 2.4-1.36 3.25M12 22a2 2 0 0 1-2-2v-2a2 2 0 1 1 4 0v2a2 2 0 0 1-2 2Zm1-11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z');
});
});
//# sourceMappingURL=Podcast.test.js.map