2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-06-19 09:50:33 +03:00

fix: allow typeAheadSelect only when option is selectable (#1529)

This commit is contained in:
Jeff Sagal
2022-02-17 16:57:27 -08:00
committed by GitHub
parent 0c72638d5e
commit 115f24aba2
5 changed files with 28 additions and 13 deletions
+16 -1
View File
@@ -1,4 +1,4 @@
import { selectWithProps } from '../helpers'
import { searchSubmit, selectWithProps } from '../helpers'
describe('Selectable prop', () => {
it('should select selectable option if clicked', async () => {
@@ -56,4 +56,19 @@ describe('Selectable prop', () => {
expect(Select.vm.typeAheadPointer).toEqual(0)
})
it('should not let the user select an unselectable option with return', async () => {
const Select = selectWithProps({
options: ['one', 'two'],
multiple: true,
selectable: (option) => option !== 'two',
})
// this sets the typeAheadPointer to 0
await searchSubmit(Select, 'one')
expect(Select.vm.selectedValue).toEqual(['one'])
await searchSubmit(Select, 'two')
expect(Select.vm.selectedValue).toEqual(['one'])
})
})