Skip to content

Commit e59ac6f

Browse files
committed
Add test
1 parent 47bf76d commit e59ac6f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/react/src/tabs/root/TabsRoot.test.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,21 @@ describe('<Tabs.Root />', () => {
184184
expect(handleChange.firstCall.args[0]).to.equal(1);
185185
});
186186

187+
it('should not call onValueChange on non-primary button clicks', async () => {
188+
const handleChange = spy();
189+
const { getAllByRole } = await render(
190+
<Tabs.Root value={0} onValueChange={handleChange}>
191+
<Tabs.List>
192+
<Tabs.Tab value={0} />
193+
<Tabs.Tab value={1} />
194+
</Tabs.List>
195+
</Tabs.Root>,
196+
);
197+
198+
fireEvent.click(getAllByRole('tab')[1], { button: 2 });
199+
expect(handleChange.callCount).to.equal(0);
200+
});
201+
187202
it('should not call onValueChange when already selected', async () => {
188203
const handleChange = spy();
189204
const { getAllByRole } = await render(

0 commit comments

Comments
 (0)