mirror of https://github.com/ElemeFE/element
Switch: set checkbox checked property
parent
11e3181a59
commit
84f8168783
|
@ -111,6 +111,7 @@
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
checked() {
|
checked() {
|
||||||
|
this.$refs.input.checked = this.checked;
|
||||||
if (this.onColor || this.offColor) {
|
if (this.onColor || this.offColor) {
|
||||||
this.setBackgroundColor();
|
this.setBackgroundColor();
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,4 +175,29 @@ describe('Switch', () => {
|
||||||
}, 10);
|
}, 10);
|
||||||
}, 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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue