@kadconsulting/dry
Version:
KAD Reusable Component Library
50 lines • 3.06 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import Icon from '../../Icon/Icon';
import { Bank } from './Bank';
import { IconSizes } from '../../Icon/IconTypes';
import { render, screen } from '@testing-library/react';
describe('Bank icon path', () => {
it('renders with a dry-prepended className', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { size: IconSizes.SMALL, Path: Bank }));
// 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-bank')).toBeTruthy();
});
it('renders the correct defaults', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Bank }));
/** 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: Bank }));
// ASSERT
expect(screen.getByTitle('bank')).toBeInTheDocument();
});
it('renders with the consumer-specified stroke color', () => {
// ARRANGE
const color = 'primary';
render(_jsx(Icon, { Path: Bank, PathProps: {
stroke: 'primary',
} }));
// ASSERT
/** Some icons consist of multiple paths; those that have multiple are grouped with a <g> element */
const pathOrGroup = screen.getByTitle('bank').parentElement?.children[1];
expect(pathOrGroup).toHaveAttribute('stroke', `var(--${color})`);
});
it('renders the correct path(s)', () => {
// ARRANGE
const { container } = render(_jsx(Icon, { Path: Bank }));
// ASSERT
const path0 = container.firstElementChild?.children[1];
expect(path0).toHaveAttribute('d', 'M3 7v8m4.5-8v8m5-8v8M17 7v8M1 16.6v.8c0 .56 0 .84.109 1.054a1 1 0 0 0 .437.437C1.76 19 2.04 19 2.6 19h14.8c.56 0 .84 0 1.054-.109a1 1 0 0 0 .437-.437C19 18.24 19 17.96 19 17.4v-.8c0-.56 0-.84-.109-1.054a1 1 0 0 0-.437-.437C18.24 15 17.96 15 17.4 15H2.6c-.56 0-.84 0-1.054.109a1 1 0 0 0-.437.437C1 15.76 1 16.04 1 16.6ZM9.653 1.077l-7.4 1.645c-.447.099-.67.149-.838.269a1 1 0 0 0-.334.417C1 3.597 1 3.826 1 4.283V5.4c0 .56 0 .84.109 1.054a1 1 0 0 0 .437.437C1.76 7 2.04 7 2.6 7h14.8c.56 0 .84 0 1.054-.109a1 1 0 0 0 .437-.437C19 6.24 19 5.96 19 5.4V4.283c0-.457 0-.686-.081-.875a1 1 0 0 0-.335-.417c-.166-.12-.39-.17-.837-.27l-7.4-1.644a2.083 2.083 0 0 0-.26-.049 1 1 0 0 0-.174 0c-.066.006-.13.02-.26.05Z');
});
});
//# sourceMappingURL=Bank.test.js.map