Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Tabs): fix tabs action style and add test unit #2808

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/tabs/TabNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const TabNav: React.FC<TabNavProps> = (props) => {
onChange = noop,
activeValue,
children,
action,
getDragProps,
} = props;

Expand Down Expand Up @@ -272,7 +273,17 @@ const TabNav: React.FC<TabNavProps> = (props) => {
<AddIcon />
</div>
) : null}
{props.action}
{action ? (
<div
className={classNames(
tdTabsClassGenerator('btn'),
tdTabsClassGenerator('nav-action'),
tdSizeClassGenerator(size),
)}
>
{action}
</div>
) : null}
</div>
<div
className={classNames(
Expand Down
22 changes: 22 additions & 0 deletions src/tabs/__tests__/tabs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,4 +340,26 @@ describe('Tabs 组件测试', () => {
expect(onDragSort.mock.calls[0][0].target.value).toEqual('vue');
expect(container.querySelectorAll('.t-tabs__nav-item-text-wrapper').item(0).firstChild.nodeValue).toEqual('react');
});

test('Tabs action', () => {
const { container } = render(
<Tabs
action="Action"
size={'medium'}
list={[
{
label: 'a',
value: 'a',
},
{
label: 'b',
value: 'b',
},
]}
/>,
);

expect(container.querySelector('.t-tabs__nav-action')).not.toBeNull();
expect(container.querySelector('.t-tabs__nav-action')).toBeInTheDocument();
});
});
Loading