Skip to content

Commit d880235

Browse files
committed
[Feature] Add ReplyIcon - address review comments
- Add title prop support for accessibility: render {title && <title>{title}</title>} inside SVG so screen readers can describe the icon - Split width/height test into two separate cases: - 'uses default width and height': renders with no props, verifies defaults (24) - 'applies custom width and height': renders with width=32 height=32, verifies custom values are applied Signed-off-by: thechillbasu <basusarthakmain@gmail.com>
1 parent e7e2799 commit d880235

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/__testing__/ReplyIcon.test.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ describe('ReplyIcon', () => {
66
render(<ReplyIcon width={24} height={24} />);
77
});
88

9-
it('applies width and height', () => {
10-
const { getByTestId } = render(<ReplyIcon width={24} height={24} />);
9+
it('uses default width and height', () => {
10+
const { getByTestId } = render(<ReplyIcon />);
1111
const svgElement = getByTestId('reply-icon-svg');
1212
expect(svgElement.getAttribute('width')).toBe('24');
1313
expect(svgElement.getAttribute('height')).toBe('24');
1414
});
15+
16+
it('applies custom width and height', () => {
17+
const { getByTestId } = render(<ReplyIcon width={32} height={32} />);
18+
const svgElement = getByTestId('reply-icon-svg');
19+
expect(svgElement.getAttribute('width')).toBe('32');
20+
expect(svgElement.getAttribute('height')).toBe('32');
21+
});
1522
});

src/icons/Reply/ReplyIcon.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const ReplyIcon = ({
55
width = DEFAULT_WIDTH,
66
height = DEFAULT_HEIGHT,
77
fill = DEFAULT_FILL_NONE,
8+
title,
89
...props
910
}: IconProps): JSX.Element => {
1011
return (
@@ -16,6 +17,7 @@ export const ReplyIcon = ({
1617
data-testid="reply-icon-svg"
1718
{...props}
1819
>
20+
{title && <title>{title}</title>}
1921
<path
2022
d="M10 9V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-10z"
2123
fill={fill}

0 commit comments

Comments
 (0)