Skip to content

Commit

Permalink
add a test to assert that falsey items can be selected
Browse files Browse the repository at this point in the history
  • Loading branch information
joshfarrant committed Jan 29, 2025
1 parent 26d17a0 commit 24bdeea
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/react/src/ActionMenu/ActionMenu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,23 @@ describe('ActionMenu', () => {
{timeout: 100},
)
})

it('should allow falsey items to be selected', () => {
const mockOnSelect = jest.fn()

const {getByRole} = render(
<ActionMenu onSelect={mockOnSelect} selectionVariant="single">
<ActionMenu.Button>Open menu</ActionMenu.Button>
<ActionMenu.Overlay aria-label="Actions">
<ActionMenu.Item value="test">Test string</ActionMenu.Item>
<ActionMenu.Item value="">Empty string</ActionMenu.Item>
</ActionMenu.Overlay>
</ActionMenu>,
)

fireEvent.click(getByRole('button', {name: 'Open menu'}))
fireEvent.click(getByRole('menuitemradio', {name: 'Empty string'}))

expect(mockOnSelect).toHaveBeenCalledWith('')
})
})

0 comments on commit 24bdeea

Please sign in to comment.