[bugfix] Checkbox: label-position prop not work

This commit is contained in:
陈嘉涵
2019-05-31 21:36:04 +08:00
parent 898ba11483
commit df275a0168
6 changed files with 56 additions and 12 deletions

View File

@@ -59,7 +59,6 @@
line-height: @checkbox-size;
&--left {
float: left;
margin: 0 @checkbox-label-margin 0 0;
}

View File

@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`label disabled 1`] = `
<div role="checkbox" tabindex="0" aria-checked="undefined" class="van-checkbox">
<div class="van-checkbox__icon van-checkbox__icon--round"><i class="van-icon van-icon-success">
<!----></i></div><span class="van-checkbox__label">Label</span>
</div>
`;
exports[`label-position prop 1`] = `
<div role="checkbox" tabindex="0" aria-checked="undefined" class="van-checkbox"><span class="van-checkbox__label van-checkbox__label--left">Label</span>
<div class="van-checkbox__icon van-checkbox__icon--round"><i class="van-icon van-icon-success">
<!----></i></div>
</div>
`;

View File

@@ -31,8 +31,8 @@ test('disabled', () => {
test('label disabled', () => {
const wrapper = mount(Checkbox, {
slots: {
default: '<div />'
scopedSlots: {
default: () => 'Label'
},
propsData: {
labelDisabled: true
@@ -41,6 +41,7 @@ test('label disabled', () => {
wrapper.find('.van-checkbox__label').trigger('click');
expect(wrapper.emitted('input')).toBeFalsy();
expect(wrapper).toMatchSnapshot();
});
test('checkbox group', async () => {
@@ -91,3 +92,16 @@ test('click event', () => {
icon.trigger('click');
expect(onClick).toHaveBeenCalledTimes(2);
});
test('label-position prop', () => {
const wrapper = mount(Checkbox, {
scopedSlots: {
default: () => 'Label'
},
propsData: {
labelPosition: 'left'
}
});
expect(wrapper).toMatchSnapshot();
});