@@ -24,6 +24,7 @@ const CONTENT1 = 'Content one'
2424const CONTENT2 = 'Content two'
2525
2626const ACTION1 = 'Action1'
27+ const ACTION2 = 'Action2'
2728
2829type RenderTabsProps = {
2930 tabsProps ?: TabsProps
@@ -54,6 +55,9 @@ describe('Tabs', () => {
5455 < TabAction href = "https://github.com/channel-io/bezier-react" >
5556 { ACTION1 }
5657 </ TabAction >
58+ < TabAction >
59+ { ACTION2 }
60+ </ TabAction >
5761 </ TabActions >
5862 </ TabList >
5963
@@ -196,6 +200,32 @@ describe('Tabs', () => {
196200 } )
197201 } )
198202
203+ describe ( 'Tab Actions' , ( ) => {
204+ describe ( 'ARIA' , ( ) => {
205+ it ( 'should have \'role="toolbar"\' attribute.' , ( ) => {
206+ const { getByRole } = renderTabs ( )
207+ expect ( getByRole ( 'toolbar' , { name : 'More actions' } ) ) . toBeInTheDocument ( )
208+ } )
209+ } )
210+
211+ describe ( 'Keyboard Navigation' , ( ) => {
212+ it ( 'can control by arrow right and left key' , async ( ) => {
213+ const { getByRole } = renderTabs ( )
214+ const tabItem1 = getByRole ( 'link' , { name : ACTION1 } )
215+ const tabItem2 = getByRole ( 'button' , { name : ACTION2 } )
216+
217+ await user . click ( getByRole ( 'link' , { name : ACTION1 } ) )
218+ expect ( document . activeElement ) . toBe ( tabItem1 )
219+ await user . keyboard ( '{arrowright}' )
220+ expect ( document . activeElement ) . toBe ( tabItem2 )
221+ await user . keyboard ( '{arrowleft}' )
222+ expect ( document . activeElement ) . toBe ( tabItem1 )
223+ await user . keyboard ( '{arrowleft}' )
224+ expect ( document . activeElement ) . toBe ( tabItem2 )
225+ } )
226+ } )
227+ } )
228+
199229 describe ( 'Tab Content' , ( ) => {
200230 describe ( 'ARIA' , ( ) => {
201231 it ( 'should have \'role="tabpanel"\' attribute.' , ( ) => {
0 commit comments