Skip to content

Commit

Permalink
test: add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
sungik-choi committed Dec 23, 2024
1 parent 2bf0713 commit 8eb5c3d
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions packages/bezier-react/src/components/AlphaIcon/Icon.test.tsx
Original file line number Diff line number Diff line change
@@ -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(
<Icon
source={ChannelBtnFilledIcon}
{...props}
/>
)

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()
})
})
})

0 comments on commit 8eb5c3d

Please sign in to comment.