Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SegmentedControl)!: new Style and add icon #995

Merged
merged 10 commits into from
Sep 30, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SegmentedControl } from './segmented-control';
const buttonGroup = [
{ label: 'Option 1', value: 'option1' },
{ label: 'Option 2', value: 'option2', defaultPressed: true },
{ label: 'Option 3', value: 'option3' },
{ label: 'Option 3', value: 'option3', disabled: true },
{ label: 'Option 4', value: 'option4' },
];

Expand All @@ -25,6 +25,20 @@ describe('SegmentedControl', () => {
expect(getByTestId(wrapper, 'test-toggle-button-1').prop('pressed')).toBe(true);
});

test('should have aria-pressed="true" for the default pressed button', () => {
const wrapper = shallow(<SegmentedControl buttonGroup={buttonGroup} groupName="Test2" />);
const button = getByTestId(wrapper, 'test-toggle-button-1');

expect(button.prop('aria-pressed')).toBe(true);
});

test('should have aria-disabled="true" for disabled button', () => {
const wrapper = shallow(<SegmentedControl buttonGroup={buttonGroup} groupName="Test" />);
const button = getByTestId(wrapper, 'test-toggle-button-2');

expect(button.prop('aria-disabled')).toBe(true);
});

test('Matches snapshot (desktop)', () => {
const tree = renderWithProviders(
<SegmentedControl buttonGroup={buttonGroup} groupName="Test4" />,
Expand Down
Loading