Skip to content

Commit

Permalink
test: Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Al-Dani committed Aug 24, 2023
1 parent 238295e commit 8205d48
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,31 @@ const items: ButtonDropdownProps.Items = [
expect(menuElement.getElement()).toHaveAccessibleName('Custom label');
});

it('does not label dropdown with icon trigger', () => {
it('does not auto-label dropdown with icon trigger', () => {
const wrapper = renderButtonDropdown({ ...props, variant: 'icon' });
wrapper.openDropdown();
const menuElement = wrapper.findOpenDropdown()!.find('[role="menu"]')!;
expect(menuElement.getElement()).not.toHaveAttribute('aria-labelledby');
});
it('passes aria-label to icon trigger', () => {
const wrapper = renderButtonDropdown({ ...props, variant: 'icon', ariaLabel: 'Button trigger' });
wrapper.openDropdown();
const menuElement = wrapper.findOpenDropdown()!.find('[role="menu"]')!;
expect(menuElement.getElement()).toHaveAccessibleName('Button trigger');
});

it('does not auto-label dropdown with inline icon trigger', () => {
const wrapper = renderButtonDropdown({ ...props, variant: 'inline-icon' });
wrapper.openDropdown();
const menuElement = wrapper.findOpenDropdown()!.find('[role="menu"]')!;
expect(menuElement.getElement()).not.toHaveAttribute('aria-labelledby');
});
it('passes aria-label to inline icon trigger', () => {
const wrapper = renderButtonDropdown({ ...props, variant: 'inline-icon', ariaLabel: 'Button trigger' });
wrapper.openDropdown();
const menuElement = wrapper.findOpenDropdown()!.find('[role="menu"]')!;
expect(menuElement.getElement()).toHaveAccessibleName('Button trigger');
});
});
});

Expand Down

0 comments on commit 8205d48

Please sign in to comment.