@@ -16,7 +16,7 @@ afterEach(() => {
1616
1717function setup ( ) {
1818 const { getByTestId} = render ( `
19- <section data-testid='a -section'>
19+ <section aria-label="a region" data-testid='named -section'>
2020 <a href="http://whatever.com" data-testid="a-link">link</a>
2121 <a>invalid link</a>
2222
@@ -50,7 +50,7 @@ function setup() {
5050 </tbody>
5151 </table>
5252
53- <form data-testid='a -form'>
53+ <form aria-label="a form" data-testid='named -form'>
5454 <input type='radio' data-testid='a-radio-1' />
5555 <input type='radio' data-testid='a-radio-2' />
5656 <input type='text' data-testid='a-input-1' />
@@ -62,12 +62,16 @@ function setup() {
6262 <li data-testid='b-list-item-1'>Item 1</li>
6363 <li data-testid='b-list-item-2'>Item 2</li>
6464 </ul>
65+
66+ <form data-testid="a-form" />
67+ <section data-testid="a-section" />
6568 </article>
6669</section>
6770 ` )
6871
6972 return {
7073 unnamedSection : getByTestId ( 'a-section' ) ,
74+ namedSection : getByTestId ( 'named-section' ) ,
7175 anchor : getByTestId ( 'a-link' ) ,
7276 h1 : getByTestId ( 'a-h1' ) ,
7377 h2 : getByTestId ( 'a-h2' ) ,
@@ -89,6 +93,7 @@ function setup() {
8993 td2 : getByTestId ( 'a-cell-2' ) ,
9094 td3 : getByTestId ( 'a-cell-3' ) ,
9195 unnamedForm : getByTestId ( 'a-form' ) ,
96+ namedForm : getByTestId ( 'named-form' ) ,
9297 radio : getByTestId ( 'a-radio-1' ) ,
9398 radio2 : getByTestId ( 'a-radio-2' ) ,
9499 input : getByTestId ( 'a-input-1' ) ,
@@ -99,7 +104,6 @@ function setup() {
99104
100105test ( 'getRoles returns expected roles for various dom nodes' , ( ) => {
101106 const {
102- unnamedSection,
103107 anchor,
104108 h1,
105109 h2,
@@ -125,9 +129,11 @@ test('getRoles returns expected roles for various dom nodes', () => {
125129 input,
126130 input2,
127131 textarea,
132+ namedSection,
133+ namedForm,
128134 } = setup ( )
129135
130- expect ( getRoles ( unnamedSection ) ) . toEqual ( {
136+ expect ( getRoles ( namedSection ) ) . toEqual ( {
131137 link : [ anchor ] ,
132138 heading : [ h1 , h2 , h3 ] ,
133139 navigation : [ nav ] ,
@@ -142,20 +148,22 @@ test('getRoles returns expected roles for various dom nodes', () => {
142148 rowgroup : [ tbody ] ,
143149 command : [ menuItem , menuItem2 ] ,
144150 menuitem : [ menuItem , menuItem2 ] ,
151+ form : [ namedForm ] ,
152+ region : [ namedSection ] ,
145153 } )
146154} )
147155
148156test ( 'logRoles calls console.log with output from prettyRoles' , ( ) => {
149- const { unnamedSection } = setup ( )
150- logRoles ( unnamedSection )
157+ const { namedSection } = setup ( )
158+ logRoles ( namedSection )
151159 expect ( console . log ) . toHaveBeenCalledTimes ( 1 )
152160 expect ( console . log . mock . calls [ 0 ] [ 0 ] ) . toMatchSnapshot ( )
153161} )
154162
155163test ( 'getImplicitAriaRoles returns expected roles for various dom nodes' , ( ) => {
156- const { unnamedSection , h1, unnamedForm, radio, input} = setup ( )
164+ const { namedSection , h1, unnamedForm, radio, input} = setup ( )
157165
158- expect ( getImplicitAriaRoles ( unnamedSection ) ) . toEqual ( [ ] )
166+ expect ( getImplicitAriaRoles ( namedSection ) ) . toEqual ( [ 'region' ] )
159167 expect ( getImplicitAriaRoles ( h1 ) ) . toEqual ( [ 'heading' ] )
160168 expect ( getImplicitAriaRoles ( unnamedForm ) ) . toEqual ( [ ] )
161169 expect ( getImplicitAriaRoles ( radio ) ) . toEqual ( [ 'radio' ] )
0 commit comments