File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
packages/bezier-react/src/components/AlphaIcon Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { ChannelBtnFilledIcon } from '@channel.io/bezier-icons'
2
+ import { render , screen } from '@testing-library/react'
3
+
4
+ import { Icon } from './Icon'
5
+
6
+ describe ( 'Icon' , ( ) => {
7
+ const renderIcon = ( props = { } ) =>
8
+ render (
9
+ < Icon
10
+ source = { ChannelBtnFilledIcon }
11
+ { ...props }
12
+ />
13
+ )
14
+
15
+ it ( 'should render' , ( ) => {
16
+ renderIcon ( )
17
+ expect ( screen . getByRole ( 'img' , { hidden : true } ) ) . toBeInTheDocument ( )
18
+ } )
19
+
20
+ describe ( 'Accessibility' , ( ) => {
21
+ it ( 'should be decorative by default' , ( ) => {
22
+ renderIcon ( )
23
+ expect ( screen . getByRole ( 'img' , { hidden : true } ) ) . toHaveAttribute (
24
+ 'aria-hidden' ,
25
+ 'true'
26
+ )
27
+ } )
28
+
29
+ it ( 'should be accessible with aria-label' , ( ) => {
30
+ renderIcon ( { 'aria-label' : 'Channel Button' } )
31
+ expect ( screen . getByRole ( 'img' ) ) . toHaveAttribute (
32
+ 'aria-label' ,
33
+ 'Channel Button'
34
+ )
35
+ expect ( screen . getByRole ( 'img' ) ) . toBeInTheDocument ( )
36
+ } )
37
+
38
+ it ( 'should respect explicit aria-hidden' , ( ) => {
39
+ renderIcon ( { 'aria-hidden' : false } )
40
+ expect ( screen . getByRole ( 'img' ) ) . toBeInTheDocument ( )
41
+ } )
42
+ } )
43
+ } )
You can’t perform that action at this time.
0 commit comments