2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-05-26 04:34:04 +03:00
added regression test to ensure values are deleted properly
This commit is contained in:
Jeff Sagal
2016-03-11 14:38:19 -08:00
parent f0f7c671ce
commit 3b60efa9b7
2 changed files with 35 additions and 2 deletions
+2 -2
View File
@@ -288,8 +288,8 @@
},
maybeDeleteValue() {
if( ! this.$els.search.value.length ) {
this.value.pop();
if( ! this.$els.search.value.length && this.value ) {
return this.multiple ? this.value.pop() : this.$set('value', null)
}
}
},
+33
View File
@@ -66,6 +66,39 @@ describe('Select.vue', () => {
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', () => {
const vm = new Vue({
template: '<div><v-select :value.sync="value"></v-select></div>',