mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
@@ -1,15 +1,20 @@
|
||||
import pointerScroll from '../../src/mixins/pointerScroll'
|
||||
import { mountDefault } from '../helpers'
|
||||
|
||||
describe('Automatic Scrolling', () => {
|
||||
let spy
|
||||
afterEach(() => {
|
||||
if (spy) spy.mockClear()
|
||||
})
|
||||
|
||||
it('should check if the scroll position needs to be adjusted on up arrow keyUp', async () => {
|
||||
// Given
|
||||
spy = jest.spyOn(pointerScroll.methods, 'maybeAdjustScroll')
|
||||
const Select = mountDefault()
|
||||
const spy = jest.spyOn(Select.vm, 'maybeAdjustScroll')
|
||||
Select.vm.typeAheadPointer = 1
|
||||
|
||||
// When
|
||||
Select.findComponent({ ref: 'search' }).trigger('keydown.up')
|
||||
await Select.vm.$nextTick()
|
||||
await Select.get('input').trigger('keydown.up')
|
||||
|
||||
// Then
|
||||
expect(spy).toHaveBeenCalled()
|
||||
@@ -17,13 +22,12 @@ describe('Automatic Scrolling', () => {
|
||||
|
||||
it('should check if the scroll position needs to be adjusted on down arrow keyUp', async () => {
|
||||
// Given
|
||||
spy = jest.spyOn(pointerScroll.methods, 'maybeAdjustScroll')
|
||||
const Select = mountDefault()
|
||||
const spy = jest.spyOn(Select.vm, 'maybeAdjustScroll')
|
||||
Select.vm.typeAheadPointer = 1
|
||||
|
||||
// When
|
||||
Select.findComponent({ ref: 'search' }).trigger('keydown.down')
|
||||
await Select.vm.$nextTick()
|
||||
await Select.get('input').trigger('keydown.down')
|
||||
|
||||
// Then
|
||||
expect(spy).toHaveBeenCalled()
|
||||
@@ -31,8 +35,8 @@ describe('Automatic Scrolling', () => {
|
||||
|
||||
it('should check if the scroll position needs to be adjusted when filtered options changes', async () => {
|
||||
// Given
|
||||
spy = jest.spyOn(pointerScroll.methods, 'maybeAdjustScroll')
|
||||
const Select = mountDefault()
|
||||
const spy = jest.spyOn(Select.vm, 'maybeAdjustScroll')
|
||||
Select.vm.typeAheadPointer = 1
|
||||
|
||||
// When
|
||||
@@ -45,10 +49,10 @@ describe('Automatic Scrolling', () => {
|
||||
|
||||
it('should not adjust scroll position when autoscroll is false', async () => {
|
||||
// Given
|
||||
spy = jest.spyOn(pointerScroll.methods, 'maybeAdjustScroll')
|
||||
const Select = mountDefault({
|
||||
autoscroll: false,
|
||||
})
|
||||
const spy = jest.spyOn(Select.vm, 'maybeAdjustScroll')
|
||||
Select.vm.typeAheadPointer = 1
|
||||
|
||||
// When
|
||||
|
||||
Reference in New Issue
Block a user