Skip to content

Commit

Permalink
chore(Icon): adds tests
Browse files Browse the repository at this point in the history
  • Loading branch information
langz committed Jun 13, 2024
1 parent d2f9a01 commit d2ced20
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/dnb-eufemia/src/components/icon/__tests__/Icon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ describe('Icon component', () => {
).toBe('custom-data-testid-value')
})

it('should work when icon property is provided a functional component with a hook', () => {
const FunctionalComponentWithHookIcon = () => {
const [title] = React.useState('banana')

return (
<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
<title>{title}</title>
<path d="M23.625 17.864A3.547 3.547 0 0120.45 23H3.548a3.546 3.546 0 01-3.172-5.136l8.45-14.902a3.548 3.548 0 016.347 0l8.452 14.902z" />
</svg>
)
}
render(
<Icon icon={FunctionalComponentWithHookIcon} inherit_color={false} />
)
expect(document.querySelector('svg title').textContent).toBe('banana')
})

it('should validate with ARIA rules', async () => {
const Comp = render(<Icon {...props} />)
expect(await axeComponent(Comp)).toHaveNoViolations()
Expand Down

0 comments on commit d2ced20

Please sign in to comment.