[improvement] Field: add clear event (#1944)

This commit is contained in:
neverland
2018-10-17 13:14:07 +08:00
committed by GitHub
parent fcd5a53cf7
commit 995ae8c300
5 changed files with 65 additions and 1 deletions
+18
View File
@@ -131,3 +131,21 @@ test('maxlength', async() => {
expect(input.element.value).toEqual('123');
expect(wrapper.emitted('input')[0][0]).toEqual('123');
});
test('clearable', () => {
const wrapper = mount(Field, {
propsData: {
value: 'test',
clearable: true
}
});
expect(wrapper).toMatchSnapshot();
const input = wrapper.find('input');
input.trigger('focus');
expect(wrapper).toMatchSnapshot();
wrapper.find('.van-field__clear').trigger('touchstart');
expect(wrapper.emitted('input')[0][0]).toEqual('');
expect(wrapper.emitted('clear')).toBeTruthy();
});