@@ -12,6 +12,12 @@ describe('<TabPanel>', () => {
1212 getByText ( 'test' ) . should . exist ;
1313 } ) ;
1414
15+ it ( 'should render a TabPanel with role tabpanel' , ( ) => {
16+ const { getByRole } = render ( < TabPanel active > test</ TabPanel > ) ;
17+
18+ getByRole ( 'tabpanel' ) . should . exist ;
19+ } ) ;
20+
1521 it ( 'should not render if not active and mountOnEnter=true' , ( ) => {
1622 const { queryByText } = render ( < TabPanel mountOnEnter > test</ TabPanel > ) ;
1723
@@ -82,6 +88,44 @@ describe('<TabPanel>', () => {
8288 } ) ;
8389
8490 describe ( 'useTabPanel' , ( ) => {
91+ it ( 'should have role set to tabpanel' , ( ) => {
92+ let props : any ;
93+ function Wrapper ( wrapperProps : any ) {
94+ const [ _props ] = useTabPanel ( wrapperProps ) ;
95+ props = _props ;
96+ return null ;
97+ }
98+
99+ render ( < Wrapper /> ) ;
100+
101+ props . role . should . equal ( 'tabpanel' ) ;
102+ } ) ;
103+
104+ it ( 'should have role tabpanel also within a context' , ( ) => {
105+ let props : any ;
106+ function Wrapper ( wrapperProps : any ) {
107+ const [ _props ] = useTabPanel ( wrapperProps ) ;
108+ props = _props ;
109+ return null ;
110+ }
111+
112+ render (
113+ < TabContext . Provider
114+ value = { {
115+ onSelect : sinon . spy ( ) ,
116+ mountOnEnter : true ,
117+ unmountOnExit : false ,
118+ getControlledId : sinon . spy ( ) ,
119+ getControllerId : sinon . spy ( ) ,
120+ } }
121+ >
122+ < Wrapper />
123+ </ TabContext . Provider > ,
124+ ) ;
125+
126+ props . role . should . equal ( 'tabpanel' ) ;
127+ } ) ;
128+
85129 it ( 'should use mountOnEnter from props if provided' , ( ) => {
86130 let meta : any ;
87131 function Wrapper ( wrapperProps : any ) {
0 commit comments