@@ -17,7 +17,7 @@ describe('DatePicker', () => {
17
17
expect ( wrapper . find ( '.mx-datepicker-popup' ) . exists ( ) ) . toBe ( false ) ;
18
18
// expect click input should show the popup
19
19
const input = wrapper . find ( 'input' ) ;
20
- await input . trigger ( 'mousedown ' ) ;
20
+ await input . trigger ( 'click ' ) ;
21
21
expect ( wrapper . find ( '.mx-datepicker-popup' ) . exists ( ) ) . toBe ( true ) ;
22
22
// expect click out side should hide the popup
23
23
const bodyWrapper = createWrapper ( document . body ) ;
@@ -296,28 +296,31 @@ describe('DatePicker', () => {
296
296
expect ( popup . element . parentNode ) . toBe ( document . body ) ;
297
297
} ) ;
298
298
299
- it ( 'feat: should emit clear event when click clear button' , ( ) => {
299
+ it ( 'feat: should emit clear event when click clear button' , async ( ) => {
300
300
wrapper = shallowMount ( DatePicker , {
301
301
propsData : {
302
302
value : new Date ( 2019 , 10 , 9 ) ,
303
303
} ,
304
304
} ) ;
305
+ await wrapper . find ( '.mx-input-wrapper' ) . trigger ( 'mouseenter' ) ;
305
306
const clearButton = wrapper . find ( '.mx-icon-clear' ) ;
306
- clearButton . trigger ( 'mousedown' ) ;
307
+
308
+ clearButton . trigger ( 'click' ) ;
307
309
const emitted = wrapper . emitted ( ) ;
308
310
expect ( emitted . clear ) . toBeTruthy ( ) ;
309
311
expect ( emitted . input [ 0 ] [ 0 ] ) . toBe ( null ) ;
310
312
} ) ;
311
313
312
- it ( 'feat: should emit [null, null] when clear range' , ( ) => {
314
+ it ( 'feat: should emit [null, null] when clear range' , async ( ) => {
313
315
wrapper = shallowMount ( DatePicker , {
314
316
propsData : {
315
317
range : true ,
316
318
value : [ new Date ( 2019 , 10 , 9 ) , new Date ( 2019 , 11 , 9 ) ] ,
317
319
} ,
318
320
} ) ;
321
+ await wrapper . find ( '.mx-input-wrapper' ) . trigger ( 'mouseenter' ) ;
319
322
const clearButton = wrapper . find ( '.mx-icon-clear' ) ;
320
- clearButton . trigger ( 'mousedown ' ) ;
323
+ clearButton . trigger ( 'click ' ) ;
321
324
const emitted = wrapper . emitted ( ) ;
322
325
expect ( emitted . input [ 0 ] [ 0 ] ) . toEqual ( [ null , null ] ) ;
323
326
} ) ;
0 commit comments