Switch: set checkbox checked property

This commit is contained in:
wacky6.AriesMBP 2017-08-01 16:57:07 +10:00 committed by 杨奕
parent 11e3181a59
commit 84f8168783
2 changed files with 26 additions and 0 deletions

View File

@ -111,6 +111,7 @@
},
watch: {
checked() {
this.$refs.input.checked = this.checked;
if (this.onColor || this.offColor) {
this.setBackgroundColor();
}

View File

@ -175,4 +175,29 @@ describe('Switch', () => {
}, 10);
}, 10);
});
it('sets checkbox value', done => {
vm = createVue({
template: `
<div>
<el-switch v-model="value"></el-switch>
</div>
`,
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);
});
});