feat(Field): add clear-trigger prop (#6699)

This commit is contained in:
neverland
2020-07-04 12:18:25 +08:00
committed by GitHub
parent ebe4036e1a
commit db09f29aa8
5 changed files with 36 additions and 17 deletions
@@ -9,7 +9,7 @@ exports[`arrow-direction prop 1`] = `
</div>
`;
exports[`clearable 1`] = `
exports[`clearable prop 1`] = `
<div class="van-cell van-field">
<div class="van-cell__value van-cell__value--alone van-field__value">
<div class="van-field__body"><input type="text" class="van-field__control"></div>
@@ -17,7 +17,7 @@ exports[`clearable 1`] = `
</div>
`;
exports[`clearable 2`] = `
exports[`clearable prop 2`] = `
<div class="van-cell van-field">
<div class="van-cell__value van-cell__value--alone van-field__value">
<div class="van-field__body"><input type="text" class="van-field__control"><i class="van-icon van-icon-clear van-field__clear">
+13 -1
View File
@@ -184,7 +184,7 @@ test('maxlength', async () => {
expect(wrapper.emitted('input')[0][0]).toEqual('123');
});
test('clearable', () => {
test('clearable prop', () => {
const wrapper = mount(Field, {
propsData: {
value: 'test',
@@ -202,6 +202,18 @@ test('clearable', () => {
expect(wrapper.emitted('clear')[0][0]).toBeTruthy();
});
test('clear-trigger prop', () => {
const wrapper = mount(Field, {
propsData: {
value: 'test',
clearable: true,
clearTrigger: 'always',
},
});
expect(wrapper.contains('.van-field__clear')).toBeTruthy();
});
test('render input slot', () => {
const wrapper = mount(Field, {
scopedSlots: {