From c821ccbf2b2884df84e39ad6696f2e15dd89ac82 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Thu, 3 Dec 2020 20:20:40 +0800 Subject: [PATCH] test(Search): improve test coverage --- src/search/test/index.spec.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/search/test/index.spec.js b/src/search/test/index.spec.js index 0ff37f431..644d995b7 100644 --- a/src/search/test/index.spec.js +++ b/src/search/test/index.spec.js @@ -119,3 +119,21 @@ test('should render action text when using action-text prop', () => { expect(wrapper.find('.van-search__action').html()).toMatchSnapshot(); }); + +test('should call input.focus when vm.focus is called', () => { + const wrapper = mount(Search); + const onFocus = jest.fn(); + wrapper.find('input').element.focus = onFocus; + + wrapper.vm.focus(); + expect(onFocus).toHaveBeenCalledTimes(1); +}); + +test('should call input.blur when vm.blur is called', () => { + const wrapper = mount(Search); + const onBlur = jest.fn(); + wrapper.find('input').element.blur = onBlur; + + wrapper.vm.blur(); + expect(onBlur).toHaveBeenCalledTimes(1); +});