@kadconsulting/dry
Version:
KAD Reusable Component Library
50 lines • 2.88 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import Icon from '../../Icon/Icon';
import { Briefcase02 } from './Briefcase02';
import { IconSizes } from '../../Icon/IconTypes';
import { render, screen } from '@testing-library/react';
describe('Briefcase02 icon path', () => {
it('renders with a dry-prepended className', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { size: IconSizes.SMALL, Path: Briefcase02 }));
// 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-briefcase-02')).toBeTruthy();
});
it('renders the correct defaults', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Briefcase02 }));
/** 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: Briefcase02 }));
// ASSERT
expect(screen.getByTitle('briefcase-02')).toBeInTheDocument();
});
it('renders with the consumer-specified stroke color', () => {
// ARRANGE
const color = 'primary';
render(_jsx(Icon, { Path: Briefcase02, PathProps: {
stroke: 'primary',
} }));
// ASSERT
/** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */
const pathOrGroup = screen.getByTitle('briefcase-02').parentElement?.children[1];
expect(pathOrGroup).toHaveAttribute('stroke', `var(--${color})`);
});
it('renders the correct path(s)', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Briefcase02 }));
// ASSERT
const path0 = container.firstElementChild?.children[1];
expect(path0).toHaveAttribute('d', 'M8 21V7c0-.93 0-1.395.102-1.776a3 3 0 0 1 2.121-2.122C10.605 3 11.07 3 12 3c.93 0 1.395 0 1.777.102a3 3 0 0 1 2.12 2.122C16 5.605 16 6.07 16 7v14M5.2 21h13.6c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C22 19.48 22 18.92 22 17.8v-7.6c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C20.48 7 19.92 7 18.8 7H5.2c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C2 8.52 2 9.08 2 10.2v7.6c0 1.12 0 1.68.218 2.108a2 2 0 0 0 .874.874C3.52 21 4.08 21 5.2 21Z');
});
});
//# sourceMappingURL=Briefcase02.test.js.map