mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[Improvement] add checkbox labelDisabled test case (#650)
This commit is contained in:
parent
d7403a0241
commit
1e10a65a18
@ -90,6 +90,7 @@ export default {
|
|||||||
|-----------|-----------|-----------|-------------|-------------|
|
|-----------|-----------|-----------|-------------|-------------|
|
||||||
| name | Checkbox name | `Boolean` | `false` | - |
|
| name | Checkbox name | `Boolean` | `false` | - |
|
||||||
| disabled | Diable checkbox | `Boolean` | `false` | - |
|
| disabled | Diable checkbox | `Boolean` | `false` | - |
|
||||||
|
| label-disabled | Whether to disable label click | `Boolean` | `false` | - |
|
||||||
| shape | Checkbox shape | `String` | `round` | `square` |
|
| shape | Checkbox shape | `String` | `round` | `square` |
|
||||||
|
|
||||||
### CheckboxGroup API
|
### CheckboxGroup API
|
||||||
|
@ -100,8 +100,8 @@ export default create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onClick(flag) {
|
onClick(target) {
|
||||||
if (!this.isDisabled && (flag !== 'label' || (flag === 'label' && !this.labelDisabled))) {
|
if (!this.isDisabled && !(target === 'label' && this.labelDisabled)) {
|
||||||
this.currentValue = !this.currentValue;
|
this.currentValue = !this.currentValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,4 +194,21 @@ describe('Checkbox', () => {
|
|||||||
|
|
||||||
expect(wrapper.vm.currentValue).to.be.false;
|
expect(wrapper.vm.currentValue).to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('click on a disabled checkbox label', () => {
|
||||||
|
wrapper = mount(Checkbox, {
|
||||||
|
propsData: {
|
||||||
|
value: false,
|
||||||
|
labelDisabled: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.hasClass('van-checkbox')).to.be.true;
|
||||||
|
expect(wrapper.vm.currentValue).to.be.false;
|
||||||
|
|
||||||
|
const checkboxLabel = wrapper.find('.van-checkbox__label')[0];
|
||||||
|
checkboxLabel.trigger('click');
|
||||||
|
|
||||||
|
expect(wrapper.vm.currentValue).to.be.false;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user