@@ -123,26 +123,6 @@ describe('Panel', function () {
123
123
assert . ok ( anchor . className . match ( / \b c o l l a p s e d \b / ) ) ;
124
124
} ) ;
125
125
126
- it ( 'Should be aria-expanded=true' , function ( ) {
127
- let instance = ReactTestUtils . renderIntoDocument (
128
- < Panel collapsible = { true } expanded = { true } header = "Heading" > Panel content</ Panel >
129
- ) ;
130
- let collapse = React . findDOMNode ( instance ) . querySelector ( '.panel-collapse' ) ;
131
- let anchor = React . findDOMNode ( instance ) . querySelector ( '.panel-title a' ) ;
132
- assert . equal ( collapse . getAttribute ( 'aria-expanded' ) , 'true' ) ;
133
- assert . equal ( anchor . getAttribute ( 'aria-expanded' ) , 'true' ) ;
134
- } ) ;
135
-
136
- it ( 'Should be aria-expanded=false' , function ( ) {
137
- let instance = ReactTestUtils . renderIntoDocument (
138
- < Panel collapsible = { true } expanded = { false } header = "Heading" > Panel content</ Panel >
139
- ) ;
140
- let collapse = React . findDOMNode ( instance ) . querySelector ( '.panel-collapse' ) ;
141
- let anchor = React . findDOMNode ( instance ) . querySelector ( '.panel-title a' ) ;
142
- assert . equal ( collapse . getAttribute ( 'aria-expanded' ) , 'false' ) ;
143
- assert . equal ( anchor . getAttribute ( 'aria-expanded' ) , 'false' ) ;
144
- } ) ;
145
-
146
126
it ( 'Should call onSelect handler' , function ( done ) {
147
127
function handleSelect ( e , key ) {
148
128
assert . equal ( key , '1' ) ;
@@ -204,4 +184,40 @@ describe('Panel', function () {
204
184
assert . equal ( children [ 0 ] . nodeName , 'TABLE' ) ;
205
185
assert . notOk ( children [ 0 ] . className . match ( / \b p a n e l - b o d y \b / ) ) ;
206
186
} ) ;
187
+
188
+ describe ( 'Web Accessibility' , function ( ) {
189
+
190
+ it ( 'Should be aria-expanded=true' , function ( ) {
191
+ let instance = ReactTestUtils . renderIntoDocument (
192
+ < Panel collapsible = { true } expanded = { true } header = "Heading" > Panel content</ Panel >
193
+ ) ;
194
+ let collapse = React . findDOMNode ( instance ) . querySelector ( '.panel-collapse' ) ;
195
+ let anchor = React . findDOMNode ( instance ) . querySelector ( '.panel-title a' ) ;
196
+ assert . equal ( collapse . getAttribute ( 'aria-expanded' ) , 'true' ) ;
197
+ assert . equal ( anchor . getAttribute ( 'aria-expanded' ) , 'true' ) ;
198
+ } ) ;
199
+
200
+ it ( 'Should be aria-expanded=false' , function ( ) {
201
+ let instance = ReactTestUtils . renderIntoDocument (
202
+ < Panel collapsible = { true } expanded = { false } header = "Heading" > Panel content</ Panel >
203
+ ) ;
204
+ let collapse = React . findDOMNode ( instance ) . querySelector ( '.panel-collapse' ) ;
205
+ let anchor = React . findDOMNode ( instance ) . querySelector ( '.panel-title a' ) ;
206
+ assert . equal ( collapse . getAttribute ( 'aria-expanded' ) , 'false' ) ;
207
+ assert . equal ( anchor . getAttribute ( 'aria-expanded' ) , 'false' ) ;
208
+ } ) ;
209
+
210
+ it ( 'Should add aria-controls with id' , function ( ) {
211
+ let instance = ReactTestUtils . renderIntoDocument (
212
+ < Panel id = 'panel-1' collapsible expanded header = "Heading" > Panel content</ Panel >
213
+ ) ;
214
+
215
+ let collapse = React . findDOMNode ( instance ) . querySelector ( '.panel-collapse' ) ;
216
+ let anchor = React . findDOMNode ( instance ) . querySelector ( '.panel-title a' ) ;
217
+
218
+ assert . equal ( collapse . getAttribute ( 'id' ) , 'panel-1' ) ;
219
+ assert . equal ( anchor . getAttribute ( 'aria-controls' ) , 'panel-1' ) ;
220
+ } ) ;
221
+
222
+ } ) ;
207
223
} ) ;
0 commit comments