@@ -16,7 +16,7 @@ afterEach(() => {
16
16
17
17
function setup ( ) {
18
18
const { getByTestId} = render ( `
19
- <section data-testid='a -section'>
19
+ <section aria-label="a region" data-testid='named -section'>
20
20
<a href="http://whatever.com" data-testid="a-link">link</a>
21
21
<a>invalid link</a>
22
22
@@ -50,7 +50,7 @@ function setup() {
50
50
</tbody>
51
51
</table>
52
52
53
- <form data-testid='a -form'>
53
+ <form aria-label="a form" data-testid='named -form'>
54
54
<input type='radio' data-testid='a-radio-1' />
55
55
<input type='radio' data-testid='a-radio-2' />
56
56
<input type='text' data-testid='a-input-1' />
@@ -62,12 +62,16 @@ function setup() {
62
62
<li data-testid='b-list-item-1'>Item 1</li>
63
63
<li data-testid='b-list-item-2'>Item 2</li>
64
64
</ul>
65
+
66
+ <form data-testid="a-form" />
67
+ <section data-testid="a-section" />
65
68
</article>
66
69
</section>
67
70
` )
68
71
69
72
return {
70
73
unnamedSection : getByTestId ( 'a-section' ) ,
74
+ namedSection : getByTestId ( 'named-section' ) ,
71
75
anchor : getByTestId ( 'a-link' ) ,
72
76
h1 : getByTestId ( 'a-h1' ) ,
73
77
h2 : getByTestId ( 'a-h2' ) ,
@@ -89,6 +93,7 @@ function setup() {
89
93
td2 : getByTestId ( 'a-cell-2' ) ,
90
94
td3 : getByTestId ( 'a-cell-3' ) ,
91
95
unnamedForm : getByTestId ( 'a-form' ) ,
96
+ namedForm : getByTestId ( 'named-form' ) ,
92
97
radio : getByTestId ( 'a-radio-1' ) ,
93
98
radio2 : getByTestId ( 'a-radio-2' ) ,
94
99
input : getByTestId ( 'a-input-1' ) ,
@@ -99,7 +104,6 @@ function setup() {
99
104
100
105
test ( 'getRoles returns expected roles for various dom nodes' , ( ) => {
101
106
const {
102
- unnamedSection,
103
107
anchor,
104
108
h1,
105
109
h2,
@@ -125,9 +129,11 @@ test('getRoles returns expected roles for various dom nodes', () => {
125
129
input,
126
130
input2,
127
131
textarea,
132
+ namedSection,
133
+ namedForm,
128
134
} = setup ( )
129
135
130
- expect ( getRoles ( unnamedSection ) ) . toEqual ( {
136
+ expect ( getRoles ( namedSection ) ) . toEqual ( {
131
137
link : [ anchor ] ,
132
138
heading : [ h1 , h2 , h3 ] ,
133
139
navigation : [ nav ] ,
@@ -142,20 +148,22 @@ test('getRoles returns expected roles for various dom nodes', () => {
142
148
rowgroup : [ tbody ] ,
143
149
command : [ menuItem , menuItem2 ] ,
144
150
menuitem : [ menuItem , menuItem2 ] ,
151
+ form : [ namedForm ] ,
152
+ region : [ namedSection ] ,
145
153
} )
146
154
} )
147
155
148
156
test ( 'logRoles calls console.log with output from prettyRoles' , ( ) => {
149
- const { unnamedSection } = setup ( )
150
- logRoles ( unnamedSection )
157
+ const { namedSection } = setup ( )
158
+ logRoles ( namedSection )
151
159
expect ( console . log ) . toHaveBeenCalledTimes ( 1 )
152
160
expect ( console . log . mock . calls [ 0 ] [ 0 ] ) . toMatchSnapshot ( )
153
161
} )
154
162
155
163
test ( 'getImplicitAriaRoles returns expected roles for various dom nodes' , ( ) => {
156
- const { unnamedSection , h1, unnamedForm, radio, input} = setup ( )
164
+ const { namedSection , h1, unnamedForm, radio, input} = setup ( )
157
165
158
- expect ( getImplicitAriaRoles ( unnamedSection ) ) . toEqual ( [ ] )
166
+ expect ( getImplicitAriaRoles ( namedSection ) ) . toEqual ( [ 'region' ] )
159
167
expect ( getImplicitAriaRoles ( h1 ) ) . toEqual ( [ 'heading' ] )
160
168
expect ( getImplicitAriaRoles ( unnamedForm ) ) . toEqual ( [ ] )
161
169
expect ( getImplicitAriaRoles ( radio ) ) . toEqual ( [ 'radio' ] )
0 commit comments