Tests: Check selection when clicked element has no value

This commit is contained in:
KoloMl 2024-08-31 23:32:55 +04:00
parent 914aa75a8e
commit 7a6ca5b234

View file

@ -187,6 +187,24 @@ describe('Suggestions', () => {
expect(itemSelectedHandler).toBeCalledTimes(1);
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', () => {