@@ -35,21 +35,23 @@ describe('SubNavigation with dropdown options', () => {
3535 }
3636
3737 it ( 'renders hidden dropdown modal with provided options' , ( ) => {
38- const { container, getByRole } = render ( < SubNavigation { ...mockProps } /> )
38+ const { container } = render ( < SubNavigation { ...mockProps } /> )
3939
40- const button = getByRole ( ' button')
40+ const button = container . querySelector ( '[data-o-header-subnav-dropdown- button] ')
4141 expect ( button ) . toBeInTheDocument ( )
4242 expect ( button ) . toHaveAttribute ( 'data-trackable' , 'Markets Data' )
43- expect ( button ) . toHaveAttribute ( 'tabIndex' , '0' )
44- expect ( button . tagName ) . toBe ( 'SPAN' )
43+ expect ( button ) . toHaveAttribute ( 'id' , 'subnav-dropdown-button-markets-data' )
44+ expect ( button ) . toHaveAttribute ( 'aria-controls' , 'subnav-dropdown-modal-markets-data' )
45+ expect ( button ) . toHaveAttribute ( 'aria-haspopup' , 'dialog' )
46+ expect ( button ) . toHaveAttribute ( 'aria-expanded' , 'false' )
4547
46- const dropdown = container . querySelector ( '[data-o-header-subnav-dropdown]' )
48+ const dropdown = container . querySelector ( '[data-o-header-subnav-dropdown-modal ]' )
4749 expect ( dropdown ) . toBeInTheDocument ( )
48- expect ( dropdown ) . toHaveAttribute ( 'aria-hidden' , 'true' )
49- expect ( dropdown ) . toHaveAttribute ( 'aria-expanded' , 'false' )
50+ expect ( dropdown ) . toHaveAttribute ( 'id' , 'subnav-dropdown-modal-markets-data' )
5051 expect ( dropdown ) . toHaveAttribute ( 'role' , 'dialog' )
5152 expect ( dropdown ) . toHaveAttribute ( 'aria-modal' , 'true' )
52- expect ( dropdown ) . toHaveAttribute ( 'aria-label' , 'Markets Data' )
53+ expect ( dropdown ) . toHaveAttribute ( 'aria-labelledby' , 'subnav-dropdown-button-markets-data' )
54+ expect ( dropdown ) . not . toHaveAttribute ( 'aria-label' )
5355
5456 const title = container . querySelector ( '.o-header__subnav-dropdown-title' )
5557 expect ( title ) . toBeInTheDocument ( )
@@ -58,7 +60,6 @@ describe('SubNavigation with dropdown options', () => {
5860 const closeButton = container . querySelector ( '[data-o-header-subnav-dropdown-close]' )
5961 expect ( closeButton ) . toBeInTheDocument ( )
6062 expect ( closeButton ) . toHaveAttribute ( 'aria-label' , 'Close menu' )
61- expect ( closeButton ) . toHaveAttribute ( 'role' , 'button' )
6263 const closeIcon = container . querySelector ( '.o-header__subnav-dropdown-close-icon' )
6364 expect ( closeIcon ) . toBeInTheDocument ( )
6465
@@ -90,15 +91,15 @@ describe('SubNavigation with dropdown options', () => {
9091 }
9192 }
9293
93- const { container, getAllByRole, queryByRole } = render ( < SubNavigation { ...propsWithoutDropdowns } /> )
94+ const { container, getAllByRole } = render ( < SubNavigation { ...propsWithoutDropdowns } /> )
9495
9596 const links = getAllByRole ( 'link' )
9697 const overviewLink = links . find ( ( link ) => link . textContent === 'Markets Overview' )
9798 expect ( overviewLink ) . toBeInTheDocument ( )
9899 expect ( overviewLink ) . toHaveAttribute ( 'href' , '/markets-overview' )
99100
100- const dropdown = container . querySelector ( '[data-o-header-subnav-dropdown]' )
101- const button = queryByRole ( ' button')
101+ const dropdown = container . querySelector ( '[data-o-header-subnav-dropdown-modal ]' )
102+ const button = container . querySelector ( '[data-o-header-subnav-dropdown- button] ')
102103 expect ( dropdown ) . not . toBeInTheDocument ( )
103104 expect ( button ) . not . toBeInTheDocument ( )
104105 } )
@@ -126,15 +127,15 @@ describe('SubNavigation with dropdown options', () => {
126127 }
127128 }
128129
129- const { container, getAllByRole, queryByRole } = render ( < SubNavigation { ...propsWithDropdownsDisabled } /> )
130+ const { container, getAllByRole } = render ( < SubNavigation { ...propsWithDropdownsDisabled } /> )
130131
131132 const links = getAllByRole ( 'link' )
132133 const overviewLink = links . find ( ( link ) => link . textContent === 'Markets Overview' )
133134 expect ( overviewLink ) . toBeInTheDocument ( )
134135 expect ( overviewLink ) . toHaveAttribute ( 'href' , '/markets-overview' )
135136
136- const dropdown = container . querySelector ( '[data-o-header-subnav-dropdown]' )
137- const button = queryByRole ( ' button')
137+ const dropdown = container . querySelector ( '[data-o-header-subnav-dropdown-modal ]' )
138+ const button = container . querySelector ( '[data-o-header-subnav-dropdown- button] ')
138139 expect ( dropdown ) . not . toBeInTheDocument ( )
139140 expect ( button ) . not . toBeInTheDocument ( )
140141 } )
0 commit comments