@kadconsulting/dry
Version:
KAD Reusable Component Library
50 lines • 3.15 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import Icon from '../../Icon/Icon';
import { Save03 } from './Save03';
import { IconSizes } from '../../Icon/IconTypes';
import { render, screen } from '@testing-library/react';
describe('Save03 icon path', () => {
it('renders with a dry-prepended className', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { size: IconSizes.SMALL, Path: Save03 }));
// 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-save-03')).toBeTruthy();
});
it('renders the correct defaults', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Save03 }));
/** 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: Save03 }));
// ASSERT
expect(screen.getByTitle('save-03')).toBeInTheDocument();
});
it('renders with the consumer-specified stroke color', () => {
// ARRANGE
const color = 'primary';
render(_jsx(Icon, { Path: Save03, PathProps: {
stroke: 'primary',
} }));
// ASSERT
/** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */
const pathOrGroup = screen.getByTitle('save-03').parentElement?.children[1];
expect(pathOrGroup).toHaveAttribute('stroke', `var(--${color})`);
});
it('renders the correct path(s)', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Save03 }));
// ASSERT
const path0 = container.firstElementChild?.children[1];
expect(path0).toHaveAttribute('d', 'M7 3h7.675c.489 0 .733 0 .963.055.204.05.4.13.579.24.201.123.374.296.72.642l3.126 3.126c.346.346.519.519.642.72.11.18.19.374.24.579.055.23.055.474.055.963V17m-8.5-7H8.6c-.56 0-.84 0-1.054-.109a1 1 0 0 1-.437-.437C7 9.24 7 8.96 7 8.4V6.5M13.5 21v-4.4c0-.56 0-.84-.109-1.054a1 1 0 0 0-.437-.437C12.74 15 12.46 15 11.9 15H8.6c-.56 0-.84 0-1.054.109a1 1 0 0 0-.437.437C7 15.76 7 16.04 7 16.6V21m10.5-10.837V17.8c0 1.12 0 1.68-.218 2.108a2 2 0 0 1-.874.874C15.98 21 15.42 21 14.3 21H6.2c-1.12 0-1.68 0-2.108-.218a2 2 0 0 1-.874-.874C3 19.48 3 18.92 3 17.8V9.7c0-1.12 0-1.68.218-2.108a2 2 0 0 1 .874-.874C4.52 6.5 5.08 6.5 6.2 6.5h7.637c.245 0 .367 0 .482.028a1 1 0 0 1 .29.12c.1.061.187.148.36.32l2.062 2.063c.173.173.26.26.322.36.054.09.095.188.12.29.027.115.027.237.027.482Z');
});
});
//# sourceMappingURL=Save03.test.js.map