feat(Form): add show-error prop (#5941)

This commit is contained in:
neverland
2020-03-29 15:28:35 +08:00
committed by GitHub
parent 7b2e6acd33
commit 6ce940d0db
5 changed files with 39 additions and 1 deletions
+25
View File
@@ -406,3 +406,28 @@ test('show-error-message prop', async () => {
await submitForm(wrapper);
expect(wrapper.contains('.van-field__error-message')).toBeTruthy();
});
test('show-error prop', async () => {
const wrapper = mountForm({
template: `
<van-form :show-error="showError">
<van-field name="A" :rules="rulesA" value="" />
<van-button native-type="submit" />
</van-form>
`,
data() {
return {
...getSimpleRules(),
showError: false,
};
},
});
await submitForm(wrapper);
expect(wrapper.contains('.van-field--error')).toBeFalsy();
wrapper.setData({ showError: true });
await submitForm(wrapper);
expect(wrapper.contains('.van-field--error')).toBeTruthy();
});