From eeffc32d075d74828068cd7de84125a3078ad079 Mon Sep 17 00:00:00 2001 From: Jeff Sagal Date: Mon, 14 Mar 2016 11:59:01 -0700 Subject: [PATCH] added regression test to make sure tags are removed when close is clicked, commit 48dbade broke that functionality --- dist/build.js | 6 +++--- src/components/Select.vue | 6 +++--- test/unit/Select.spec.js | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/dist/build.js b/dist/build.js index 3cf34f8..36f7bc4 100644 --- a/dist/build.js +++ b/dist/build.js @@ -10338,9 +10338,9 @@ exports.default = { this.value = option; } } else { - // if (this.multiple) { - // this.value.$remove(option) - // } + if (this.multiple) { + this.value.$remove(option); + } } if (!this.multiple) { diff --git a/src/components/Select.vue b/src/components/Select.vue index af92125..cf82c21 100644 --- a/src/components/Select.vue +++ b/src/components/Select.vue @@ -221,9 +221,9 @@ this.value = option } } else { - // if (this.multiple) { - // this.value.$remove(option) - // } + if (this.multiple) { + this.value.$remove(option) + } } if (!this.multiple) { diff --git a/test/unit/Select.spec.js b/test/unit/Select.spec.js index ce061a2..b0fefd4 100644 --- a/test/unit/Select.spec.js +++ b/test/unit/Select.spec.js @@ -66,6 +66,24 @@ describe('Select.vue', () => { expect( labels ).toEqual( ['This is Foo', 'This is Bar'] ) }) + it('removes the given tag when its close icon is clicked', (done) => { + const vm = new Vue({ + template: '
', + components: { vSelect }, + data: { + value: ['one'], + options: ['one','two','three'] + } + }).$mount() + + vm.$children[0].$els.toggle.querySelector('.close').click() + + Vue.nextTick(() => { + expect(vm.$children[0].$get('value')).toEqual([]) + done() + }) + }) + it('removes the last item in the value array on delete keypress when multiple is true', () => { const vm = new Vue({