[new feature] Number: support v-model (#3531)

This commit is contained in:
neverland
2019-06-17 15:19:21 +08:00
committed by GitHub
parent 6ec870abce
commit ce3dfc859a
6 changed files with 131 additions and 3 deletions

View File

@@ -126,3 +126,25 @@ test('focus on key', () => {
trigger(key, 'touchend');
expect(wrapper).toMatchSnapshot();
});
test('controlled mode', () => {
const wrapper = mount(NumberKeyboard, {
propsData: {
value: ''
},
listeners: {
'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('12');
keys.at(11).trigger('click');
expect(wrapper.vm.value).toEqual('1');
});