@@ -354,4 +354,35 @@ describe('ActionList.Item', () => {
354354 expect ( item ) . toHaveTextContent ( 'Item, Description' )
355355 expect ( item ) . toHaveAccessibleDescription ( 'Description' )
356356 } )
357+
358+ it ( 'should add role="tab" when ActionList has role="tablist"' , ( ) => {
359+ const { getAllByRole} = HTMLRender (
360+ < ActionList role = "tablist" >
361+ < ActionList . Item > Tab 1</ ActionList . Item >
362+ < ActionList . Item > Tab 2</ ActionList . Item >
363+ < ActionList . Item > Tab 3</ ActionList . Item >
364+ </ ActionList > ,
365+ )
366+ const tabs = getAllByRole ( 'tab' )
367+ expect ( tabs [ 0 ] ) . toBeInTheDocument ( )
368+ expect ( tabs ) . toHaveLength ( 3 )
369+ } )
370+
371+ it ( 'should update stylings when aria-selected is added outside of React' , ( ) => {
372+ const { getByRole} = HTMLRender (
373+ < ActionList role = "tablist" >
374+ < ActionList . Item > Tab 1</ ActionList . Item >
375+ </ ActionList > ,
376+ )
377+
378+ const tab = getByRole ( 'tab' )
379+ expect ( tab ) . toBeInTheDocument ( )
380+
381+ const backgroundColorBefore = window . getComputedStyle ( tab ) . backgroundColor
382+ // Simulate outside of React setting aria-selected
383+ tab . setAttribute ( 'aria-selected' , 'true' )
384+ const backgroundColorAfter = window . getComputedStyle ( tab ) . backgroundColor
385+ expect ( backgroundColorBefore ) . not . toBe ( backgroundColorAfter )
386+ expect ( tab ) . toHaveAttribute ( 'aria-selected' , 'true' )
387+ } )
357388} )
0 commit comments