mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 10:44:59 +00:00
[new feature] NumberKeyboard: add maxlength prop (#3532)
This commit is contained in:
@@ -127,7 +127,7 @@ test('focus on key', () => {
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('controlled mode', () => {
|
||||
test('bind value', () => {
|
||||
const wrapper = mount(NumberKeyboard, {
|
||||
propsData: {
|
||||
value: ''
|
||||
@@ -148,3 +148,26 @@ test('controlled mode', () => {
|
||||
keys.at(11).trigger('click');
|
||||
expect(wrapper.vm.value).toEqual('1');
|
||||
});
|
||||
|
||||
test('maxlength', () => {
|
||||
const onInput = jest.fn();
|
||||
const wrapper = mount(NumberKeyboard, {
|
||||
propsData: {
|
||||
value: '',
|
||||
maxlength: 1
|
||||
},
|
||||
listeners: {
|
||||
input: onInput,
|
||||
'update:value': value => {
|
||||
wrapper.setProps({ value });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const keys = wrapper.findAll('.van-key');
|
||||
keys.at(0).trigger('click');
|
||||
keys.at(1).trigger('click');
|
||||
|
||||
expect(wrapper.vm.value).toEqual('1');
|
||||
expect(onInput).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
Reference in New Issue
Block a user