mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
Tests: Looping selection between from end to start and from start to end
This commit is contained in:
parent
098ec6c6db
commit
1fe752dca3
1 changed files with 30 additions and 0 deletions
|
@ -157,6 +157,36 @@ describe('Suggestions', () => {
|
||||||
expect(thirdItem).toHaveClass(selectedItemClassName);
|
expect(thirdItem).toHaveClass(selectedItemClassName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should loop around when selecting next on last and previous on first', () => {
|
||||||
|
[popup, input] = mockBaseSuggestionsPopup(true);
|
||||||
|
|
||||||
|
const firstItem = document.querySelector('.autocomplete__item:first-child');
|
||||||
|
const lastItem = document.querySelector('.autocomplete__item:last-child');
|
||||||
|
|
||||||
|
if (lastItem) {
|
||||||
|
fireEvent.mouseOver(lastItem);
|
||||||
|
fireEvent.mouseMove(lastItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(lastItem).toHaveClass(selectedItemClassName);
|
||||||
|
|
||||||
|
popup.selectNext();
|
||||||
|
|
||||||
|
expect(document.querySelector(`.${selectedItemClassName}`)).toBeNull();
|
||||||
|
|
||||||
|
popup.selectNext();
|
||||||
|
|
||||||
|
expect(firstItem).toHaveClass(selectedItemClassName);
|
||||||
|
|
||||||
|
popup.selectPrevious();
|
||||||
|
|
||||||
|
expect(document.querySelector(`.${selectedItemClassName}`)).toBeNull();
|
||||||
|
|
||||||
|
popup.selectPrevious();
|
||||||
|
|
||||||
|
expect(lastItem).toHaveClass(selectedItemClassName);
|
||||||
|
});
|
||||||
|
|
||||||
it('should return selected item value', () => {
|
it('should return selected item value', () => {
|
||||||
[popup, input] = mockBaseSuggestionsPopup(true);
|
[popup, input] = mockBaseSuggestionsPopup(true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue