feat(Field): add digit type (#5524)

This commit is contained in:
neverland
2020-01-09 15:28:58 +08:00
committed by GitHub
parent 47e326fb2a
commit ac3808cd47
7 changed files with 113 additions and 45 deletions
+11 -5
View File
@@ -20,21 +20,27 @@ exports[`renders demo correctly 1`] = `
</div>
</div>
<div class="van-cell van-field">
<div class="van-cell__title van-field__label"><span>密码</span></div>
<div class="van-cell__title van-field__label"><span>手机号</span></div>
<div class="van-cell__value">
<div class="van-field__body"><input type="password" placeholder="请输入密码" class="van-field__control"></div>
<div class="van-field__body"><input type="tel" placeholder="请输入手机号" class="van-field__control"></div>
</div>
</div>
<div class="van-cell van-field">
<div class="van-cell__title van-field__label"><span>整数</span></div>
<div class="van-cell__value">
<div class="van-field__body"><input type="tel" placeholder="请输入整数" class="van-field__control"></div>
</div>
</div>
<div class="van-cell van-field">
<div class="van-cell__title van-field__label"><span>数字</span></div>
<div class="van-cell__value">
<div class="van-field__body"><input type="text" placeholder="请输入数字" class="van-field__control"></div>
<div class="van-field__body"><input type="text" placeholder="请输入数字(支持小数)" class="van-field__control"></div>
</div>
</div>
<div class="van-cell van-field">
<div class="van-cell__title van-field__label"><span>手机号</span></div>
<div class="van-cell__title van-field__label"><span>密码</span></div>
<div class="van-cell__value">
<div class="van-field__body"><input type="tel" placeholder="请输入手机号" class="van-field__control"></div>
<div class="van-field__body"><input type="password" placeholder="请输入密码" class="van-field__control"></div>
</div>
</div>
</div>
+23
View File
@@ -56,6 +56,29 @@ test('number type', () => {
expect(wrapper.emitted('input')[2][0]).toEqual('123');
});
test('digit type', () => {
const wrapper = mount(Field, {
propsData: {
value: '',
type: 'digit'
}
});
const input = wrapper.find('input');
input.element.value = '1';
input.trigger('input');
expect(wrapper.emitted('input')[0][0]).toEqual('1');
input.element.value = '1.';
input.trigger('input');
expect(wrapper.emitted('input')[1][0]).toEqual('1');
input.element.value = '123abc';
input.trigger('input');
expect(wrapper.emitted('input')[2][0]).toEqual('123');
});
test('render textarea', async () => {
const wrapper = mount(Field, {
propsData: {