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:
co-authored by
dgmpk
neverland
parent
507e397d07
commit
c7024d4457
@@ -346,6 +346,7 @@ export default defineComponent({
|
|||||||
props.min ?? -Infinity,
|
props.min ?? -Infinity,
|
||||||
props.max ?? Infinity,
|
props.max ?? Infinity,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (+value !== adjustedValue) {
|
if (+value !== adjustedValue) {
|
||||||
value = adjustedValue.toString();
|
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');
|
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 () => {
|
test('should render textarea when type is textarea', async () => {
|
||||||
const wrapper = mount(Field, {
|
const wrapper = mount(Field, {
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
Reference in New Issue
Block a user