From 84f816878305c2689101fb30403749aedbf54b8c Mon Sep 17 00:00:00 2001 From: "wacky6.AriesMBP" <416707889@qq.com> Date: Tue, 1 Aug 2017 16:57:07 +1000 Subject: [PATCH] Switch: set checkbox checked property --- packages/switch/src/component.vue | 1 + test/unit/specs/switch.spec.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/packages/switch/src/component.vue b/packages/switch/src/component.vue index cf62a03f3..abe404048 100644 --- a/packages/switch/src/component.vue +++ b/packages/switch/src/component.vue @@ -111,6 +111,7 @@ }, watch: { checked() { + this.$refs.input.checked = this.checked; if (this.onColor || this.offColor) { this.setBackgroundColor(); } diff --git a/test/unit/specs/switch.spec.js b/test/unit/specs/switch.spec.js index e28a93c6a..eac43fb23 100644 --- a/test/unit/specs/switch.spec.js +++ b/test/unit/specs/switch.spec.js @@ -175,4 +175,29 @@ describe('Switch', () => { }, 10); }, 10); }); + + it('sets checkbox value', done => { + vm = createVue({ + template: ` +
+ +
+ `, + data() { + return { + value: false + }; + } + }, true); + + vm.value = true; + setTimeout(() => { + expect(vm.$el.querySelector('input').checked).to.equal(true); + vm.value = false; + setTimeout(() => { + expect(vm.$el.querySelector('input').checked).to.equal(false); + done(); + }, 10); + }, 10); + }); });