Skip to content

Commit 9ba9f9b

Browse files
committed
add test
1 parent 9612187 commit 9ba9f9b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.changeset/soft-jokes-chew.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@sumup-oss/circuit-ui": patch
33
---
44

5-
Fixed an issue with keyboard navigation in the Tabs component. Tab panels no longer part of the tab order but can be focused with keydown press.
5+
Fixed an issue with keyboard navigation in the Tabs component. Tab panels are no longer part of the tab order but can be focused with keydown press.

packages/circuit-ui/components/Tabs/components/Tab/Tab.spec.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* limitations under the License.
1414
*/
1515

16-
import { describe, expect, it } from 'vitest';
16+
import { describe, expect, it, vi } from 'vitest';
1717
import { createRef } from 'react';
1818

1919
import { render } from '../../../../util/test-utils.js';
@@ -34,4 +34,13 @@ describe('Tab', () => {
3434
const button = container.querySelector('button');
3535
expect(ref.current).toBe(button);
3636
});
37+
38+
it('should be focused when selected', () => {
39+
const ref = createRef<HTMLButtonElement>();
40+
const { container, rerender } = render(<Tab ref={ref} selected={false} />);
41+
const button = container.querySelector('button');
42+
vi.spyOn(button, 'focus');
43+
rerender(<Tab ref={ref} selected />);
44+
expect(button?.focus).toHaveBeenCalledOnce();
45+
});
3746
});

0 commit comments

Comments
 (0)