@@ -34,7 +34,9 @@ describe('Avatar', () => {
3434 </ Avatar >
3535 ) ;
3636
37- expect ( getByText ( badge ) ) . not . toBeEmptyDOMElement ( ) ;
37+ const element = getByText ( badge ) ;
38+
39+ expect ( element ) . toHaveAttribute ( 'aria-hidden' ) ;
3840 } ) ;
3941
4042 it ( 'applies active styling to available status if provided with badge' , ( ) => {
@@ -75,49 +77,48 @@ describe('Avatar', () => {
7577 </ Avatar >
7678 ) ;
7779
78- const statusIndicatorElement = getByText ( '2' ) ?. parentElement ;
80+ const element = getByText ( 'status: active. 2 notifications' ) ;
7981
80- expect ( statusIndicatorElement ) . toHaveAttribute (
81- 'aria-label' ,
82- 'status: active. 2 notifications'
83- ) ;
82+ expect ( element ) . toBeInTheDocument ( ) ;
8483 } ) ;
8584
8685 it ( 'renders with badge and with a provided status label' , ( ) => {
86+ const label = 'two notifications' ;
8787 const { getByText } = render (
88- < Avatar badge = "2" statusLabel = "two notifications" >
88+ < Avatar badge = "2" statusLabel = { label } >
8989 < img alt = "" />
9090 </ Avatar >
9191 ) ;
9292
93- const statusIndicatorElement = getByText ( '2' ) ?. parentElement ;
93+ const element = getByText ( label ) ;
9494
95- expect ( statusIndicatorElement ) . toHaveAttribute ( 'aria-label' , 'two notifications' ) ;
95+ expect ( element ) . toBeInTheDocument ( ) ;
9696 } ) ;
9797
98- it ( 'renders with status and applies default aria- label for available status' , ( ) => {
99- const { getByLabelText } = render (
98+ it ( 'renders with status and applies default label for available status' , ( ) => {
99+ const { getByText } = render (
100100 < Avatar status = "available" >
101101 < img alt = "" />
102102 </ Avatar >
103103 ) ;
104104
105- const statusIndicatorElement = getByLabelText ( 'status: available' ) ;
105+ const element = getByText ( 'status: available' ) ;
106106
107- expect ( statusIndicatorElement ) . toBeEmptyDOMElement ( ) ;
107+ expect ( element ) . toBeInTheDocument ( ) ;
108108 } ) ;
109109
110- it ( 'renders with status and applies default aria- label for away status' , ( ) => {
111- const { getByLabelText , container } = render (
110+ it ( 'renders with status and applies default label for away status' , ( ) => {
111+ const { getByText , container } = render (
112112 < Avatar status = "away" >
113113 < img alt = "" />
114114 </ Avatar >
115115 ) ;
116116
117- const statusIndicatorElement = getByLabelText ( 'status: away' ) ;
117+ const element = getByText ( 'status: away' ) ;
118118 const statusIndicatorSVG = container . querySelector ( 'svg' ) ;
119119
120- expect ( statusIndicatorElement ) . toContainElement ( statusIndicatorSVG ) ;
120+ expect ( element ) . toBeInTheDocument ( ) ;
121+ expect ( statusIndicatorSVG ) . toBeInTheDocument ( ) ;
121122 } ) ;
122123 } ) ;
123124
0 commit comments