Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hassanad94 committed Oct 30, 2023
1 parent 9c81754 commit 5975261
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/sn-pickers-react/src/components/search-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export function SearchPicker<T extends GenericContentWithIsParent = GenericConte
<List>
{props.items.map((item) => (
<div
data-testid="search-list-item-container"
onClick={(e) => onCheckedChangeHandler(e, item as any)}
onDoubleClick={(e) => e.stopPropagation()}
key={item.Id}>
Expand Down
20 changes: 19 additions & 1 deletion packages/sn-pickers-react/tests/search-picker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Search picker component', () => {
expect(wrapper.findWhere((node) => node.name() === 'input' && node.prop('checked') === true)).toHaveLength(1)
})

it('should handle selection on click', async () => {
it('should handle selection on click', async () => {
let wrapper: any
await act(async () => {
wrapper = mount(
Expand All @@ -46,6 +46,24 @@ describe('Search picker component', () => {
})

expect(wrapper.findWhere((node) => node.name() === 'input' && node.prop('checked') === true)).toHaveLength(1)

//Double click should not change the selection

await act(async () => {
await wrapper.find(ListItem).at(3).simulate('dblclick')
wrapper.update()
})

expect(wrapper.findWhere((node) => node.name() === 'input' && node.prop('checked') === true)).toHaveLength(1)

//parent Double Click should not change the selection

await act(async () => {
await wrapper.find(ListItem).at(3).closest("[data-testid='search-list-item-container']").simulate('dblclick')
wrapper.update()
})

expect(wrapper.findWhere((node) => node.name() === 'input' && node.prop('checked') === true)).toHaveLength(1)
})

it('should handle multiple selection', async () => {
Expand Down

0 comments on commit 5975261

Please sign in to comment.