fix(Field): should not get formValue from button slot (#5785)

This commit is contained in:
chenjiahan
2020-03-09 19:18:16 +08:00
parent ecce907de7
commit 09ad95ca68
2 changed files with 35 additions and 4 deletions
+23
View File
@@ -196,3 +196,26 @@ test('use uploader', async () => {
await submitForm(wrapper);
expect(onSubmit).toHaveBeenCalledWith({ A: [{ url: 'foo' }] });
});
test('should not get formValue from button slot', async () => {
const onSubmit = jest.fn();
const wrapper = mountForm({
template: `
<van-form @submit="onSubmit">
<van-field name="A" value="foo" :rules="[{ required: true, message: 'foo' }]">
<template #button>
<van-checkbox :value="false" />
</template>
</van-field>
<van-button native-type="submit" />
</van-form>
`,
methods: {
onSubmit,
},
});
await submitForm(wrapper);
expect(onSubmit).toHaveBeenCalledWith({ A: 'foo' });
});