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 048b73d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 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,25 @@ 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, user } = await render(
<Tabs.Root value={0} onValueChange={handleChange}>
<Tabs.List>
<Tabs.Tab value={0} />
<Tabs.Tab value={1} />
</Tabs.List>
</Tabs.Root>,
);
await user.pointer({ keys: '[MouseRight]', target: getAllByRole('tab')[1] });

expect(handleChange.callCount).to.equal(0);

await user.pointer({ keys: '[MouseMiddle]', target: getAllByRole('tab')[1] });

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 048b73d

Please sign in to comment.