diff --git a/packages/bezier-react/src/components/AlphaIcon/Icon.test.tsx b/packages/bezier-react/src/components/AlphaIcon/Icon.test.tsx new file mode 100644 index 000000000..3ff9f3d38 --- /dev/null +++ b/packages/bezier-react/src/components/AlphaIcon/Icon.test.tsx @@ -0,0 +1,43 @@ +import { ChannelBtnFilledIcon } from '@channel.io/bezier-icons' +import { render, screen } from '@testing-library/react' + +import { Icon } from './Icon' + +describe('Icon', () => { + const renderIcon = (props = {}) => + render( + + ) + + it('should render', () => { + renderIcon() + expect(screen.getByRole('img', { hidden: true })).toBeInTheDocument() + }) + + describe('Accessibility', () => { + it('should be decorative by default', () => { + renderIcon() + expect(screen.getByRole('img', { hidden: true })).toHaveAttribute( + 'aria-hidden', + 'true' + ) + }) + + it('should be accessible with aria-label', () => { + renderIcon({ 'aria-label': 'Channel Button' }) + expect(screen.getByRole('img')).toHaveAttribute( + 'aria-label', + 'Channel Button' + ) + expect(screen.getByRole('img')).toBeInTheDocument() + }) + + it('should respect explicit aria-hidden', () => { + renderIcon({ 'aria-hidden': false }) + expect(screen.getByRole('img')).toBeInTheDocument() + }) + }) +})