mirror of
https://github.com/youzan/vant.git
synced 2025-10-14 23:20:41 +00:00
test(Field): should not modify the value if it's within the min/max (#13343)
Co-authored-by: dgmpk <465316497@qq.com> Co-authored-by: neverland <jait.chen@foxmail.com>
This commit is contained in:
@@ -346,6 +346,7 @@ export default defineComponent({
|
||||
props.min ?? -Infinity,
|
||||
props.max ?? Infinity,
|
||||
);
|
||||
|
||||
if (+value !== adjustedValue) {
|
||||
value = adjustedValue.toString();
|
||||
}
|
||||
|
@@ -123,6 +123,23 @@ test('should limit input value based on min and max props', async () => {
|
||||
expect(wrapper.emitted('update:modelValue')[2][0]).toEqual('5');
|
||||
});
|
||||
|
||||
test('should not modify the value if it is within the min/max', async () => {
|
||||
const wrapper = mount(Field, {
|
||||
props: {
|
||||
type: 'number',
|
||||
min: 2,
|
||||
max: 10,
|
||||
modelValue: '',
|
||||
},
|
||||
});
|
||||
|
||||
const input = wrapper.find('input');
|
||||
|
||||
await wrapper.setProps({ modelValue: '2.00' });
|
||||
await input.trigger('blur');
|
||||
expect(wrapper.emitted('update:modelValue')).toBeFalsy();
|
||||
});
|
||||
|
||||
test('should render textarea when type is textarea', async () => {
|
||||
const wrapper = mount(Field, {
|
||||
props: {
|
||||
|
Reference in New Issue
Block a user