Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mj12albert committed Jan 10, 2025
1 parent 47bf76d commit e59ac6f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/react/src/tabs/root/TabsRoot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,21 @@ describe('<Tabs.Root />', () => {
expect(handleChange.firstCall.args[0]).to.equal(1);
});

it('should not call onValueChange on non-primary button clicks', async () => {
const handleChange = spy();
const { getAllByRole } = await render(
<Tabs.Root value={0} onValueChange={handleChange}>
<Tabs.List>
<Tabs.Tab value={0} />
<Tabs.Tab value={1} />
</Tabs.List>
</Tabs.Root>,
);

fireEvent.click(getAllByRole('tab')[1], { button: 2 });
expect(handleChange.callCount).to.equal(0);
});

it('should not call onValueChange when already selected', async () => {
const handleChange = spy();
const { getAllByRole } = await render(
Expand Down

0 comments on commit e59ac6f

Please sign in to comment.