input 基本事件 - MTTTM/vue-keyboard-cn GitHub Wiki
获取焦点 失去焦点 输入事件
import { mount } from '@vue/test-utils'
import Input from './xx.vue'
import KeyBoard from './xx.vue'
describe('Counter', () => {
// 现在挂载组件,你便得到了这个包裹器
const wrapper1 = mount(Input)
const wrapper2 = mount(Input)
const KeyBoardInstance = mount(KeyBoard)
const wrapper2Root=createWrapper(wrapper1.vm.$root);
//测试获取焦点
const domInput1 = wrapper1.find('.keyboard-input')
const domInput2 = wrapper1.find('.keyboard-input')
await domInput1.trigger("click");
expect(wrapper1.emitted().focus).toBeTruthy()
//失去就焦点测试
await domInput2.trigger("click");
expect(wrapper1.emitted().blur).toBeTruthy()
//键盘隐藏导致失去焦点
await domInput1.trigger("click");
this.$root.$emit(EventKeys["vue-keyboard-cn-show"], false);
expect(wrapper1.emitted().blur).toBeTruthy()
//输入事件
await domInput1.trigger("click");
this.$root.$emit(EventKeys["vue-keyboard-cn-append-item"],"1");
expect(wrapper1.emitted().input).toBeTruthy()
})