mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
Tests: Check selection when clicked element has no value
This commit is contained in:
parent
914aa75a8e
commit
7a6ca5b234
1 changed files with 18 additions and 0 deletions
|
@ -187,6 +187,24 @@ describe('Suggestions', () => {
|
||||||
expect(itemSelectedHandler).toBeCalledTimes(1);
|
expect(itemSelectedHandler).toBeCalledTimes(1);
|
||||||
expect(clickEvent?.detail).toEqual(mockedSuggestionsResponse[0]);
|
expect(clickEvent?.detail).toEqual(mockedSuggestionsResponse[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not emit selection on items without value', () => {
|
||||||
|
[popup, input] = mockBaseSuggestionsPopup();
|
||||||
|
|
||||||
|
popup.renderSuggestions([{ label: 'Option without value', value: '' }]);
|
||||||
|
|
||||||
|
const itemSelectionHandler = vi.fn();
|
||||||
|
|
||||||
|
popup.onItemSelected(itemSelectionHandler);
|
||||||
|
|
||||||
|
const firstItem = document.querySelector('.autocomplete__item:first-child')!;
|
||||||
|
|
||||||
|
if (firstItem) {
|
||||||
|
fireEvent.click(firstItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(itemSelectionHandler).not.toBeCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('fetchSuggestions', () => {
|
describe('fetchSuggestions', () => {
|
||||||
|
|
Loading…
Reference in a new issue