@@ -17,7 +17,7 @@ describe('DatePicker', () => {
1717 expect ( wrapper . find ( '.mx-datepicker-popup' ) . exists ( ) ) . toBe ( false ) ;
1818 // expect click input should show the popup
1919 const input = wrapper . find ( 'input' ) ;
20- await input . trigger ( 'mousedown ' ) ;
20+ await input . trigger ( 'click ' ) ;
2121 expect ( wrapper . find ( '.mx-datepicker-popup' ) . exists ( ) ) . toBe ( true ) ;
2222 // expect click out side should hide the popup
2323 const bodyWrapper = createWrapper ( document . body ) ;
@@ -296,28 +296,31 @@ describe('DatePicker', () => {
296296 expect ( popup . element . parentNode ) . toBe ( document . body ) ;
297297 } ) ;
298298
299- it ( 'feat: should emit clear event when click clear button' , ( ) => {
299+ it ( 'feat: should emit clear event when click clear button' , async ( ) => {
300300 wrapper = shallowMount ( DatePicker , {
301301 propsData : {
302302 value : new Date ( 2019 , 10 , 9 ) ,
303303 } ,
304304 } ) ;
305+ await wrapper . find ( '.mx-input-wrapper' ) . trigger ( 'mouseenter' ) ;
305306 const clearButton = wrapper . find ( '.mx-icon-clear' ) ;
306- clearButton . trigger ( 'mousedown' ) ;
307+
308+ clearButton . trigger ( 'click' ) ;
307309 const emitted = wrapper . emitted ( ) ;
308310 expect ( emitted . clear ) . toBeTruthy ( ) ;
309311 expect ( emitted . input [ 0 ] [ 0 ] ) . toBe ( null ) ;
310312 } ) ;
311313
312- it ( 'feat: should emit [null, null] when clear range' , ( ) => {
314+ it ( 'feat: should emit [null, null] when clear range' , async ( ) => {
313315 wrapper = shallowMount ( DatePicker , {
314316 propsData : {
315317 range : true ,
316318 value : [ new Date ( 2019 , 10 , 9 ) , new Date ( 2019 , 11 , 9 ) ] ,
317319 } ,
318320 } ) ;
321+ await wrapper . find ( '.mx-input-wrapper' ) . trigger ( 'mouseenter' ) ;
319322 const clearButton = wrapper . find ( '.mx-icon-clear' ) ;
320- clearButton . trigger ( 'mousedown ' ) ;
323+ clearButton . trigger ( 'click ' ) ;
321324 const emitted = wrapper . emitted ( ) ;
322325 expect ( emitted . input [ 0 ] [ 0 ] ) . toEqual ( [ null , null ] ) ;
323326 } ) ;
0 commit comments