feat(Field): add formatter prop (#5534)

This commit is contained in:
neverland
2020-01-09 20:52:20 +08:00
committed by GitHub
parent 47c24e192c
commit 9452444a7d
6 changed files with 200 additions and 94 deletions
+18
View File
@@ -262,3 +262,21 @@ test('arrow-direction prop', () => {
});
expect(wrapper).toMatchSnapshot();
});
test('formatter prop', () => {
const wrapper = mount(Field, {
propsData: {
value: 'abc123',
formatter: (value) => value.replace(/\d/g, '')
}
});
const input = wrapper.find('input');
input.trigger('input');
expect(wrapper.emitted('input')[0][0]).toEqual('abc');
input.element.value = '123efg';
input.trigger('input');
expect(wrapper.emitted('input')[1][0]).toEqual('efg');
});