diff --git a/src/button-dropdown/__tests__/button-dropdown-accessibility.test.tsx b/src/button-dropdown/__tests__/button-dropdown-accessibility.test.tsx index 32d0818681..40c82ea1d6 100644 --- a/src/button-dropdown/__tests__/button-dropdown-accessibility.test.tsx +++ b/src/button-dropdown/__tests__/button-dropdown-accessibility.test.tsx @@ -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'); + }); }); });