Skip to content

Commit

Permalink
fix(Tab): reverting role back to button (#1197)
Browse files Browse the repository at this point in the history
  • Loading branch information
VadymBezpalko authored Jun 24, 2024
1 parent bbbe6fa commit 4c3613f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
12 changes: 6 additions & 6 deletions packages/react-components/src/components/Tab/Tab.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@ describe('<Tab> component', () => {
it('should allow for custom class', () => {
const { getByRole } = renderComponent({ className: 'custom-class' });

expect(getByRole('tab')).toHaveClass('custom-class');
expect(getByRole('button')).toHaveClass('custom-class');
});

it('should render unselected Tab by default', () => {
const { getByRole } = renderComponent({});

expect(getByRole('tab')).not.toHaveAttribute('aria-selected');
expect(getByRole('button')).not.toHaveAttribute('aria-selected');
});

it('should render selected Tab if isSelected is provided', () => {
const { getByRole } = renderComponent({ isSelected: true });

expect(getByRole('tab')).toHaveAttribute('aria-selected', 'true');
expect(getByRole('button')).toHaveAttribute('aria-selected', 'true');
});

it('should render disabled Tab if disabled is provided', () => {
const { getByRole } = renderComponent({ disabled: true });

expect(getByRole('tab')).toBeDisabled();
expect(getByRole('button')).toBeDisabled();
});

it('should render properly formatted counter', () => {
const { getByRole } = renderComponent({ count: 1 });

expect(getByRole('tab')).toHaveTextContent('(1)');
expect(getByRole('button')).toHaveTextContent('(1)');
});

it('should render properly formatted counter as a badge', () => {
Expand All @@ -46,7 +46,7 @@ describe('<Tab> component', () => {

it('should render with anchor element if href is provided', () => {
const { getByRole } = renderComponent({ href: 'http://example.com' });
const link = getByRole('tab');
const link = getByRole('link');

expect(link).toHaveTextContent('Hello');
expect(link).toHaveAttribute('href', 'http://example.com');
Expand Down
1 change: 0 additions & 1 deletion packages/react-components/src/components/Tab/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export const Tab: React.FC<React.PropsWithChildren<TabProps>> = ({
<Text
{...restProps}
as={restProps.href ? 'a' : 'button'}
role="tab"
aria-selected={isSelected}
size="md"
bold={isSelected}
Expand Down

0 comments on commit 4c3613f

Please sign in to comment.