Skip to content

Commit

Permalink
fix: wire up TabMenu.Item onClick handler which was being swallowed a…
Browse files Browse the repository at this point in the history
…fter TS refactor (#270)
  • Loading branch information
dkordik authored Sep 14, 2020
1 parent 5fe895e commit 0830a18
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/TabMenu/Item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Item: React.FC<ItemProps> = ({
[styles.active]: active || isChildActive(children),
});
return (
<li className={className} {...props}>
<li className={className} onClick={onClick} {...props}>
{children}
</li>
);
Expand Down
12 changes: 12 additions & 0 deletions src/components/TabMenu/TabMenu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ describe('TabMenu.Item', () => {

expect(inactive.prop('active')).not.toBe(true);
});

it('triggers onClick handler when clicking', () => {
const fakeClickHandler = jest.fn();
const menuItem = mount(
<TabMenu.Item onClick={fakeClickHandler}>
Clickable menu item
</TabMenu.Item>
);
menuItem.simulate('click');

expect(fakeClickHandler).toHaveBeenCalled();
});
});

describe('EasyTabMenu', () => {
Expand Down

0 comments on commit 0830a18

Please sign in to comment.