@kadconsulting/dry
Version:
KAD Reusable Component Library
50 lines • 3.23 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import Icon from '../../Icon/Icon';
import { Car02 } from './Car02';
import { IconSizes } from '../../Icon/IconTypes';
import { render, screen } from '@testing-library/react';
describe('Car02 icon path', () => {
it('renders with a dry-prepended className', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { size: IconSizes.SMALL, Path: Car02 }));
// 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-car-02')).toBeTruthy();
});
it('renders the correct defaults', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Car02 }));
/** 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: Car02 }));
// ASSERT
expect(screen.getByTitle('car-02')).toBeInTheDocument();
});
it('renders with the consumer-specified stroke color', () => {
// ARRANGE
const color = 'primary';
render(_jsx(Icon, { Path: Car02, PathProps: {
stroke: 'primary',
} }));
// ASSERT
/** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */
const pathOrGroup = screen.getByTitle('car-02').parentElement?.children[1];
expect(pathOrGroup).toHaveAttribute('stroke', `var(--${color})`);
});
it('renders the correct path(s)', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Car02 }));
// ASSERT
const path0 = container.firstElementChild?.children[1];
expect(path0).toHaveAttribute('d', 'M19 10V6.2c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C17.48 3 16.92 3 15.8 3H8.2c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C5 4.52 5 5.08 5 6.2V10m0-1H2V8m17 1h3V8M6 13.5h.01m11.99 0h.01M6.8 10h10.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C22 12.28 22 13.12 22 14.8V18c0 .932 0 1.398-.152 1.765a2 2 0 0 1-1.083 1.083C20.398 21 19.932 21 19 21h-.6c-.372 0-.557 0-.713-.025a2 2 0 0 1-1.662-1.662C16 19.157 16 18.972 16 18.6c0-.093 0-.14-.006-.178a.5.5 0 0 0-.416-.416C15.54 18 15.493 18 15.4 18H8.6c-.093 0-.14 0-.178.006a.5.5 0 0 0-.416.416C8 18.46 8 18.507 8 18.6c0 .372 0 .557-.025.713a2 2 0 0 1-1.662 1.662C6.157 21 5.972 21 5.6 21H5c-.932 0-1.398 0-1.765-.152a2 2 0 0 1-1.083-1.083C2 19.398 2 18.932 2 18v-3.2c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C4.28 10 5.12 10 6.8 10Zm-.3 3.5a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm12 0a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Z');
});
});
//# sourceMappingURL=Car02.test.js.map