Skip to content

Commit

Permalink
Merge 2c1f7fa into 354a228
Browse files Browse the repository at this point in the history
  • Loading branch information
sosohime committed Sep 24, 2019
2 parents 354a228 + 2c1f7fa commit 6121eba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/TabBarTabsNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default class TabBarTabsNode extends React.Component {
key={key}
style={ style }
{...ref}
{...(typeof child.props.tab === 'string' ? {'data-tab': child.props.tab}: {})}
>
{child.props.tab}
</div>
Expand Down
3 changes: 3 additions & 0 deletions tests/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ exports[`rc-tabs should render Tabs with correct DOM structure 1`] = `
aria-disabled="false"
aria-selected="false"
class=" rc-tabs-tab"
data-tab="tab 1"
role="tab"
>
tab 1
Expand All @@ -50,6 +51,7 @@ exports[`rc-tabs should render Tabs with correct DOM structure 1`] = `
aria-disabled="false"
aria-selected="true"
class="rc-tabs-tab-active rc-tabs-tab"
data-tab="tab 2"
role="tab"
>
tab 2
Expand All @@ -58,6 +60,7 @@ exports[`rc-tabs should render Tabs with correct DOM structure 1`] = `
aria-disabled="false"
aria-selected="false"
class=" rc-tabs-tab"
data-tab="tab 3"
role="tab"
>
tab 3
Expand Down
17 changes: 17 additions & 0 deletions tests/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,21 @@ describe('rc-tabs', () => {
done();
}, 1000);
});

it('string type tab should have [data-tab] attribute', () => {
const wrapper = mount(
<Tabs
defaultActiveKey="2"
renderTabBar={() => <ScrollableInkTabBar/>}
renderTabContent={() => <TabContent/>}
>
<TabPane tab="tab 1" key="1">first</TabPane>
<TabPane tab="tab 2" key="2">second</TabPane>
<TabPane tab="tab 3" key="3">third</TabPane>
<TabPane tab={<div>tab 4</div>} key="4">fourth</TabPane>
</Tabs>
);

expect(wrapper.find('[data-tab]').length).toBe(3);
})
});

0 comments on commit 6121eba

Please sign in to comment.