fix(Field): should limit number input in iOS (#5520)

This commit is contained in:
neverland
2020-01-09 13:58:49 +08:00
committed by GitHub
parent ccdedecee7
commit 3bfcf671b9
6 changed files with 181 additions and 127 deletions
+11 -18
View File
@@ -33,7 +33,7 @@ test('click icon event', () => {
expect(wrapper.emitted('click-right-icon')[0][0]).toBeTruthy();
});
test('keypress event', () => {
test('number type', () => {
const wrapper = mount(Field, {
propsData: {
value: '',
@@ -41,26 +41,19 @@ test('keypress event', () => {
}
});
const fn = jest.fn();
const { calls } = fn.mock;
const press = keyCode => wrapper.vm.onKeypress({
keyCode,
preventDefault: fn
});
const input = wrapper.find('input');
press(0);
expect(calls.length).toBe(1);
input.element.value = '1';
input.trigger('input');
expect(wrapper.emitted('input')[0][0]).toEqual('1');
press(50);
expect(calls.length).toBe(1);
input.element.value = '1.2.';
input.trigger('input');
expect(wrapper.emitted('input')[1][0]).toEqual('1.2');
wrapper.setProps({ value: '0.1' });
press(46);
expect(calls.length).toBe(2);
wrapper.setProps({ type: 'text' });
press(0);
expect(calls.length).toBe(2);
input.element.value = '123abc';
input.trigger('input');
expect(wrapper.emitted('input')[2][0]).toEqual('123');
});
test('render textarea', async () => {