mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-19 09:50:33 +03:00
@@ -288,8 +288,8 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
maybeDeleteValue() {
|
maybeDeleteValue() {
|
||||||
if( ! this.$els.search.value.length ) {
|
if( ! this.$els.search.value.length && this.value ) {
|
||||||
this.value.pop();
|
return this.multiple ? this.value.pop() : this.$set('value', null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -66,6 +66,39 @@ describe('Select.vue', () => {
|
|||||||
expect( labels ).toEqual( ['This is Foo', 'This is Bar'] )
|
expect( labels ).toEqual( ['This is Foo', 'This is Bar'] )
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('removes the last item in the value array on delete keypress when multiple is true', () => {
|
||||||
|
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<div><v-select :value.sync="value" :multiple="true"></v-select></div>',
|
||||||
|
components: { vSelect },
|
||||||
|
data: {
|
||||||
|
value: ['one','two'],
|
||||||
|
options: ['one','two','three']
|
||||||
|
}
|
||||||
|
}).$mount()
|
||||||
|
|
||||||
|
vm.$children[0].maybeDeleteValue()
|
||||||
|
Vue.nextTick(() => {
|
||||||
|
expect(vm.$children[0].$get('value')).toEqual(['one'])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('sets the value to null on delete keypress when multiple is false', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<div><v-select :value.sync="value"></v-select></div>',
|
||||||
|
components: { vSelect },
|
||||||
|
data: {
|
||||||
|
value: 'one',
|
||||||
|
options: ['one','two','three']
|
||||||
|
}
|
||||||
|
}).$mount()
|
||||||
|
|
||||||
|
vm.$children[0].maybeDeleteValue()
|
||||||
|
Vue.nextTick(() => {
|
||||||
|
expect(vm.$children[0].$get('value')).toEqual(null)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it('can determine if the value prop is empty', () => {
|
it('can determine if the value prop is empty', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select :value.sync="value"></v-select></div>',
|
template: '<div><v-select :value.sync="value"></v-select></div>',
|
||||||
|
|||||||
Reference in New Issue
Block a user