@@ -24,13 +24,13 @@ let items = [
24
24
{ name : 'Tab 3' , children : 'Tab 3 body' }
25
25
] ;
26
26
27
- function renderComponent ( props ) {
27
+ function renderComponent ( props , itemProps ) {
28
28
return render (
29
29
< Provider theme = { theme } >
30
30
< Tabs { ...props } items = { items } >
31
31
< TabList >
32
32
{ item => (
33
- < Item key = { item . name } title = { item . name || item . children } />
33
+ < Item { ... itemProps } key = { item . name } title = { item . name || item . children } />
34
34
) }
35
35
</ TabList >
36
36
< TabPanels >
@@ -638,12 +638,27 @@ describe('Tabs', function () {
638
638
expect ( tabPanelInput . value ) . toBe ( '' ) ;
639
639
} ) ;
640
640
641
- it ( 'supports custom props' , function ( ) {
641
+ it ( 'supports custom props for parent tabs element ' , function ( ) {
642
642
let { getByTestId} = renderComponent ( { 'data-testid' : 'tabs1' } ) ;
643
643
let tabs = getByTestId ( 'tabs1' ) ;
644
644
expect ( tabs ) . toBeInTheDocument ( ) ;
645
645
} ) ;
646
646
647
+ it ( 'supports custom props for tab items' , function ( ) {
648
+ let { getAllByTestId} = renderComponent ( { } , {
649
+ 'data-testid' : 'tabItems' ,
650
+ 'data-instance-id' : 'instance-id' ,
651
+ 'id' : 'id-1'
652
+ } ) ;
653
+ let tabItems = getAllByTestId ( 'tabItems' ) ;
654
+ expect ( tabItems ) . toHaveLength ( 3 ) ;
655
+ for ( let tabItem of tabItems ) {
656
+ expect ( tabItem ) . toHaveAttribute ( 'data-instance-id' , 'instance-id' ) ;
657
+ expect ( tabItem ) . not . toHaveAttribute ( 'id' , 'id-1' ) ;
658
+ expect ( tabItem ) . toBeInTheDocument ( ) ;
659
+ }
660
+ } ) ;
661
+
647
662
it ( 'fires onSelectionChange when clicking on the current tab' , function ( ) {
648
663
let container = renderComponent ( { defaultSelectedKey : items [ 0 ] . name , onSelectionChange} ) ;
649
664
let tablist = container . getByRole ( 'tablist' ) ;
0 commit comments