@@ -3,6 +3,7 @@ import ReactTestUtils from 'react/lib/ReactTestUtils';
33import Tabs from '../src/Tabs' ;
44import Tab from '../src/Tab' ;
55import NavItem from '../src/NavItem' ;
6+ import Nav from '../src/Nav' ;
67import ValidComponentChildren from '../src/utils/ValidComponentChildren' ;
78import { render } from './helpers' ;
89
@@ -25,7 +26,7 @@ describe('Tabs', function () {
2526 assert . equal ( tabs . refs . tabs . props . activeKey , 1 ) ;
2627 } ) ;
2728
28- it ( 'Should only show the tabs with `Tab.props.tab ` set' , function ( ) {
29+ it ( 'Should only show the tabs with `Tab.props.title ` set' , function ( ) {
2930 let instance = ReactTestUtils . renderIntoDocument (
3031 < Tabs activeKey = { 3 } >
3132 < Tab title = "Tab 1" eventKey = { 1 } > Tab 1 content</ Tab >
@@ -260,49 +261,51 @@ describe('Tabs', function () {
260261 } ) ;
261262
262263 describe ( 'Web Accessibility' , function ( ) {
263-
264- it ( 'Should generate ids from parent id' , function ( ) {
265- let instance = ReactTestUtils . renderIntoDocument (
264+ let instance ;
265+ beforeEach ( function ( ) {
266+ instance = ReactTestUtils . renderIntoDocument (
266267 < Tabs defaultActiveKey = { 2 } id = 'tabs' >
267- < Tab title = "Tab 1" eventKey = { 1 } > Tab 1 content</ Tab >
268- < Tab title = "Tab 2" eventKey = { 2 } > Tab 2 content</ Tab >
268+ < Tab id = 'pane-1' title = "Tab 1" eventKey = { 1 } > Tab 1 content</ Tab >
269+ < Tab id = 'pane-2' title = "Tab 2" eventKey = { 2 } > Tab 2 content</ Tab >
269270 </ Tabs >
270271 ) ;
272+ } ) ;
271273
274+ it ( 'Should generate ids from parent id' , function ( ) {
272275 let tabs = ReactTestUtils . scryRenderedComponentsWithType ( instance , NavItem ) ;
273276
274277 tabs . every ( tab =>
275278 assert . ok ( tab . props [ 'aria-controls' ] && tab . props . linkId ) ) ;
276279 } ) ;
277280
278281 it ( 'Should add aria-controls' , function ( ) {
279- let instance = ReactTestUtils . renderIntoDocument (
280- < Tabs defaultActiveKey = { 2 } id = 'tabs' >
281- < Tab id = 'pane-1' title = "Tab 1" eventKey = { 1 } > Tab 1 content</ Tab >
282- < Tab id = 'pane-2' title = "Tab 2" eventKey = { 2 } > Tab 2 content</ Tab >
283- </ Tabs >
284- ) ;
285-
286282 let panes = ReactTestUtils . scryRenderedComponentsWithType ( instance , Tab ) ;
287283
288284 assert . equal ( panes [ 0 ] . props [ 'aria-labelledby' ] , 'pane-1___tab' ) ;
289285 assert . equal ( panes [ 1 ] . props [ 'aria-labelledby' ] , 'pane-2___tab' ) ;
290286 } ) ;
291287
292288 it ( 'Should add aria-controls' , function ( ) {
293- let instance = ReactTestUtils . renderIntoDocument (
294- < Tabs defaultActiveKey = { 2 } id = 'tabs' >
295- < Tab id = 'pane-1' title = "Tab 1" eventKey = { 1 } > Tab 1 content</ Tab >
296- < Tab id = 'pane-2' title = "Tab 2" eventKey = { 2 } > Tab 2 content</ Tab >
297- </ Tabs >
298- ) ;
299-
300289 let tabs = ReactTestUtils . scryRenderedComponentsWithType ( instance , NavItem ) ;
301290
302291 assert . equal ( tabs [ 0 ] . props [ 'aria-controls' ] , 'pane-1' ) ;
303292 assert . equal ( tabs [ 1 ] . props [ 'aria-controls' ] , 'pane-2' ) ;
304293 } ) ;
305294
295+ it ( 'Should add role=tablist to the nav' , function ( ) {
296+ let nav = ReactTestUtils . findRenderedComponentWithType ( instance , Nav ) ;
297+
298+ assert . equal ( nav . props . role , 'tablist' ) ;
299+ } ) ;
300+
301+ it ( 'Should add aria-selected to the nav item for the selected tab' , function ( ) {
302+ let tabs = ReactTestUtils . scryRenderedComponentsWithType ( instance , NavItem ) ;
303+ let link1 = ReactTestUtils . findRenderedDOMComponentWithTag ( tabs [ 0 ] , 'a' ) ;
304+ let link2 = ReactTestUtils . findRenderedDOMComponentWithTag ( tabs [ 1 ] , 'a' ) ;
305+
306+ assert . equal ( link1 . props [ 'aria-selected' ] , undefined ) ;
307+ assert . equal ( link2 . props [ 'aria-selected' ] , true ) ;
308+ } ) ;
306309 } ) ;
307310
308311 it ( 'Should not pass className to Nav' , function ( ) {
0 commit comments