@@ -128,7 +128,7 @@ describe('<Nav>', () => {
128
128
</ NavDropdown >
129
129
</ Nav > ,
130
130
)
131
- . find ( 'DropdownItem ' )
131
+ . find ( 'a.dropdown-item ' )
132
132
. simulate ( 'click' ) ;
133
133
134
134
onSelectSpy . should . have . been . calledOnce ;
@@ -151,140 +151,6 @@ describe('<Nav>', () => {
151
151
mount ( < Nav navbar justify /> ) ;
152
152
} ) ;
153
153
154
- describe ( 'keyboard navigation' , ( ) => {
155
- let wrapper ;
156
- let selectSpy ;
157
- let keyDownSpy ;
158
-
159
- beforeEach ( ( ) => {
160
- selectSpy = sinon . spy ( ( activeKey ) => {
161
- wrapper . setProps ( { activeKey } ) ;
162
- } ) ;
163
- keyDownSpy = sinon . spy ( ) ;
164
-
165
- wrapper = mount (
166
- < Nav
167
- activeKey = { 1 }
168
- onSelect = { selectSpy }
169
- onKeyDown = { keyDownSpy }
170
- role = "tablist"
171
- >
172
- < Nav . Link eventKey = { 1 } > Nav.Link 1 content</ Nav . Link >
173
- < Nav . Link eventKey = { 2 } disabled >
174
- Nav.Link 2 content
175
- </ Nav . Link >
176
- < Nav . Link eventKey = { 3 } > Nav.Link 3 content</ Nav . Link >
177
- < Nav . Link eventKey = { 4 } disabled >
178
- Nav.Link 4 content
179
- </ Nav . Link >
180
- < Nav . Link eventKey = { 5 } > Nav.Link 5 content</ Nav . Link >
181
- </ Nav > ,
182
- { attachTo : mountPoint } ,
183
- ) ;
184
- } ) ;
185
-
186
- afterEach ( ( ) => wrapper . unmount ( ) ) ;
187
-
188
- it ( 'should not allow focusing on disabled tabs' , ( ) => {
189
- const links = wrapper . find ( 'a' ) . map ( ( n ) => n . getDOMNode ( ) ) ;
190
-
191
- expect ( links [ 0 ] . getAttribute ( 'tabindex' ) ) . to . not . equal ( '-1' ) ;
192
- expect ( links [ 1 ] . getAttribute ( 'tabindex' ) ) . to . equal ( '-1' ) ;
193
- expect ( links [ 2 ] . getAttribute ( 'tabindex' ) ) . to . not . equal ( '-1' ) ;
194
- expect ( links [ 3 ] . getAttribute ( 'tabindex' ) ) . to . equal ( '-1' ) ;
195
- expect ( links [ 4 ] . getAttribute ( 'tabindex' ) ) . to . not . equal ( '-1' ) ;
196
- } ) ;
197
-
198
- it ( 'should focus the next tab on arrow key' , ( ) => {
199
- const anchors = wrapper . find ( 'a' ) ;
200
-
201
- anchors
202
- . at ( 0 )
203
- . tap ( ( a ) => a . getDOMNode ( ) . focus ( ) )
204
- . simulate ( 'keydown' , {
205
- key : 'ArrowRight' ,
206
- } ) ;
207
-
208
- expect ( wrapper . prop ( 'activeKey' ) ) . to . equal ( '3' ) ;
209
-
210
- expect ( document . activeElement ) . to . equal ( anchors . at ( 2 ) . getDOMNode ( ) ) ;
211
- } ) ;
212
-
213
- it ( 'should focus the previous tab on arrow key' , ( ) => {
214
- wrapper . setProps ( { activeKey : 5 } ) ;
215
-
216
- const anchors = wrapper . find ( 'a' ) ;
217
-
218
- anchors
219
- . at ( 4 )
220
- . tap ( ( a ) => a . getDOMNode ( ) . focus ( ) )
221
- . simulate ( 'keydown' , {
222
- key : 'ArrowLeft' ,
223
- } ) ;
224
-
225
- expect ( wrapper . prop ( 'activeKey' ) ) . to . equal ( '3' ) ;
226
- expect ( document . activeElement ) . to . equal ( anchors . at ( 2 ) . getDOMNode ( ) ) ;
227
- } ) ;
228
-
229
- it ( 'should wrap to the next tab on arrow key' , ( ) => {
230
- wrapper . setProps ( { activeKey : 5 } ) ;
231
- const anchors = wrapper . find ( 'a' ) ;
232
-
233
- anchors
234
- . at ( 4 )
235
- . tap ( ( a ) => a . getDOMNode ( ) . focus ( ) )
236
- . simulate ( 'keydown' , {
237
- key : 'ArrowDown' ,
238
- } ) ;
239
-
240
- expect ( wrapper . prop ( 'activeKey' ) ) . to . equal ( '1' ) ;
241
- expect ( document . activeElement ) . to . equal ( anchors . at ( 0 ) . getDOMNode ( ) ) ;
242
- } ) ;
243
-
244
- it ( 'should wrap to the previous tab on arrow key' , ( ) => {
245
- const anchors = wrapper . find ( 'a' ) ;
246
-
247
- anchors
248
- . at ( 0 )
249
- . tap ( ( a ) => a . getDOMNode ( ) . focus ( ) )
250
- . simulate ( 'keydown' , {
251
- key : 'ArrowUp' ,
252
- } ) ;
253
-
254
- expect ( wrapper . prop ( 'activeKey' ) ) . to . equal ( '5' ) ;
255
- expect ( document . activeElement ) . to . equal ( anchors . at ( 4 ) . getDOMNode ( ) ) ;
256
- } ) ;
257
-
258
- it ( 'should forward to a onKeyDown listener' , ( ) => {
259
- const anchors = wrapper . find ( 'a' ) ;
260
-
261
- anchors
262
- . at ( 0 )
263
- . tap ( ( a ) => a . getDOMNode ( ) . focus ( ) )
264
- . simulate ( 'keydown' , {
265
- key : 'ArrowUp' ,
266
- } ) ;
267
-
268
- sinon . assert . calledOnce ( keyDownSpy ) ;
269
- } ) ;
270
-
271
- [ 'a' , 'b' , 'left' , 'up' ] . forEach ( ( { key } ) => {
272
- it ( `should ignore non-arrow keys: case ${ key } ` , ( ) => {
273
- const anchors = wrapper . find ( 'a' ) ;
274
-
275
- anchors
276
- . at ( 0 )
277
- . tap ( ( a ) => a . getDOMNode ( ) . focus ( ) )
278
- . simulate ( 'keydown' , {
279
- key,
280
- } ) ;
281
-
282
- expect ( document . activeElement ) . to . equal ( anchors . at ( 0 ) . getDOMNode ( ) ) ;
283
- sinon . assert . calledOnce ( keyDownSpy ) ;
284
- } ) ;
285
- } ) ;
286
- } ) ;
287
-
288
154
describe ( 'Web Accessibility' , ( ) => {
289
155
it ( 'should have tablist and tab roles' , ( ) => {
290
156
const wrapper = mount (
0 commit comments