@kadconsulting/dry
Version:
KAD Reusable Component Library
50 lines • 2.83 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import Icon from '../../Icon/Icon';
import { Rocket01 } from './Rocket01';
import { IconSizes } from '../../Icon/IconTypes';
import { render, screen } from '@testing-library/react';
describe('Rocket01 icon path', () => {
it('renders with a dry-prepended className', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { size: IconSizes.SMALL, Path: Rocket01 }));
// 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-rocket-01')).toBeTruthy();
});
it('renders the correct defaults', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Rocket01 }));
/** 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: Rocket01 }));
// ASSERT
expect(screen.getByTitle('rocket-01')).toBeInTheDocument();
});
it('renders with the consumer-specified stroke color', () => {
// ARRANGE
const color = 'primary';
render(_jsx(Icon, { Path: Rocket01, PathProps: {
stroke: 'primary',
} }));
// ASSERT
/** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */
const pathOrGroup = screen.getByTitle('rocket-01').parentElement?.children[1];
expect(pathOrGroup).toHaveAttribute('stroke', `var(--${color})`);
});
it('renders the correct path(s)', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Rocket01 }));
// ASSERT
const path0 = container.firstElementChild?.children[1];
expect(path0).toHaveAttribute('d', 'm13 11-9.5 9.5M14.018 3.538a22.613 22.613 0 0 1 3.483 2.855 22.61 22.61 0 0 1 2.876 3.515M9.255 7.896 6.38 6.938a1 1 0 0 0-.962.185L2.56 9.541a1 1 0 0 0 .3 1.701l2.708.998m6.113 6.112.997 2.708a1 1 0 0 0 1.702.3l2.417-2.857a1 1 0 0 0 .186-.962l-.959-2.875M19.348 2.27l-4.906.817a2.443 2.443 0 0 0-1.383.741L6.446 10.9a4.653 4.653 0 0 0 6.576 6.575l7.07-6.613c.391-.367.652-.853.74-1.382l.818-4.907a2 2 0 0 0-2.302-2.301Z');
});
});
//# sourceMappingURL=Rocket01.test.js.map