mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 17:51:54 +00:00
fix(Field): fix the issue of checking empty value (#7050)
* fix(Field): fix the issue of checking empty value * fix: field tests * docs: remove radio-group * docs: remove required translation key
This commit is contained in:
@@ -190,7 +190,9 @@ export default createComponent({
|
||||
if (Array.isArray(value)) {
|
||||
return !value.length;
|
||||
}
|
||||
|
||||
if (value === 0) {
|
||||
return false;
|
||||
}
|
||||
return !value;
|
||||
},
|
||||
|
||||
|
@@ -126,10 +126,7 @@ test('use stepper', async () => {
|
||||
});
|
||||
|
||||
await submitForm(wrapper);
|
||||
expect(onFailed).toHaveBeenCalledWith({
|
||||
errors: [{ message: 'foo', name: 'A' }],
|
||||
values: { A: 0 },
|
||||
});
|
||||
expect(onFailed).toBeCalledTimes(0);
|
||||
|
||||
wrapper.setData({ value: 1 });
|
||||
|
||||
@@ -146,10 +143,7 @@ test('use rate', async () => {
|
||||
});
|
||||
|
||||
await submitForm(wrapper);
|
||||
expect(onFailed).toHaveBeenCalledWith({
|
||||
errors: [{ message: 'foo', name: 'A' }],
|
||||
values: { A: 0 },
|
||||
});
|
||||
expect(onFailed).toBeCalledTimes(0);
|
||||
|
||||
wrapper.setData({ value: 1 });
|
||||
|
||||
@@ -166,10 +160,7 @@ test('use slider', async () => {
|
||||
});
|
||||
|
||||
await submitForm(wrapper);
|
||||
expect(onFailed).toHaveBeenCalledWith({
|
||||
errors: [{ message: 'foo', name: 'A' }],
|
||||
values: { A: 0 },
|
||||
});
|
||||
expect(onFailed).toBeCalledTimes(0);
|
||||
|
||||
wrapper.setData({ value: 50 });
|
||||
|
||||
|
Reference in New Issue
Block a user