test: add another scrolling test (#184)
This commit is contained in:
parent
ed63bedd61
commit
154e703a1b
|
@ -1,6 +1,6 @@
|
|||
import { basicAfterEach, basicBeforeEach, tick } from '../shared'
|
||||
import Picker from '../../../src/picker/PickerElement'
|
||||
import { getByRole, waitFor } from '@testing-library/dom'
|
||||
import { getByRole, waitFor, getAllByRole } from '@testing-library/dom'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
|
||||
describe('scrolling', () => {
|
||||
|
@ -56,4 +56,35 @@ describe('scrolling', () => {
|
|||
document.body.removeChild(picker)
|
||||
await tick(20)
|
||||
})
|
||||
|
||||
test('scrollTop resets to 0 on changing search input', async () => {
|
||||
const picker = new Picker()
|
||||
const container = picker.shadowRoot
|
||||
|
||||
document.body.appendChild(picker)
|
||||
|
||||
await waitFor(() => expect(getByRole(container, 'menuitem', { name: /😀/ })).toBeVisible())
|
||||
const tabPanel = getByRole(container, 'tabpanel')
|
||||
|
||||
await userEvent.type(getByRole(container, 'combobox'), 'monkey')
|
||||
|
||||
await waitFor(() => expect(getAllByRole(container, 'option')).toHaveLength(2))
|
||||
expect(getByRole(container, 'option', { name: /🐵/ })).toBeVisible()
|
||||
|
||||
tabPanel.scrollTop = 1
|
||||
|
||||
await tick(20)
|
||||
expect(tabPanel.scrollTop).toEqual(1)
|
||||
|
||||
await userEvent.type(getByRole(container, 'combobox'), ' face')
|
||||
|
||||
await waitFor(() => expect(getAllByRole(container, 'option')).toHaveLength(1))
|
||||
expect(getByRole(container, 'option', { name: /🐵/ })).toBeVisible()
|
||||
|
||||
await tick(20)
|
||||
expect(tabPanel.scrollTop).toEqual(0)
|
||||
|
||||
document.body.removeChild(picker)
|
||||
await tick(20)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue