@@ -196,7 +196,7 @@ describe('<TimeClock />', () => {
196
196
const onChangeMock = spy ( ) ;
197
197
render ( < TimeClock value = { adapterToUse . date ( '2019-01-01' ) } onChange = { onChangeMock } readOnly /> ) ;
198
198
199
- fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchmove ' , selectEvent ) ;
199
+ fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchstart ' , selectEvent ) ;
200
200
expect ( onChangeMock . callCount ) . to . equal ( 0 ) ;
201
201
202
202
// hours are not disabled
@@ -224,7 +224,7 @@ describe('<TimeClock />', () => {
224
224
const onChangeMock = spy ( ) ;
225
225
render ( < TimeClock value = { adapterToUse . date ( '2019-01-01' ) } onChange = { onChangeMock } disabled /> ) ;
226
226
227
- fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchmove ' , selectEvent ) ;
227
+ fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchstart ' , selectEvent ) ;
228
228
expect ( onChangeMock . callCount ) . to . equal ( 0 ) ;
229
229
230
230
// hours are disabled
@@ -252,7 +252,7 @@ describe('<TimeClock />', () => {
252
252
} ,
253
253
] ,
254
254
} ,
255
- '20 :--' : {
255
+ '19 :--' : {
256
256
changedTouches : [
257
257
{
258
258
clientX : 66 ,
@@ -292,7 +292,7 @@ describe('<TimeClock />', () => {
292
292
/> ,
293
293
) ;
294
294
295
- fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchmove ' , clockTouchEvent [ '13:--' ] ) ;
295
+ fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchstart ' , clockTouchEvent [ '13:--' ] ) ;
296
296
297
297
expect ( handleChange . callCount ) . to . equal ( 1 ) ;
298
298
const [ date , selectionState ] = handleChange . firstCall . args ;
@@ -316,7 +316,7 @@ describe('<TimeClock />', () => {
316
316
/> ,
317
317
) ;
318
318
319
- fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchmove ' , clockTouchEvent [ '--:20' ] ) ;
319
+ fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchstart ' , clockTouchEvent [ '--:20' ] ) ;
320
320
321
321
expect ( handleChange . callCount ) . to . equal ( 1 ) ;
322
322
const [ date , selectionState ] = handleChange . firstCall . args ;
@@ -338,7 +338,7 @@ describe('<TimeClock />', () => {
338
338
/> ,
339
339
) ;
340
340
341
- fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchmove ' , clockTouchEvent [ '--:20' ] ) ;
341
+ fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchstart ' , clockTouchEvent [ '--:20' ] ) ;
342
342
343
343
expect ( handleChange . callCount ) . to . equal ( 0 ) ;
344
344
} ) ;
@@ -356,7 +356,7 @@ describe('<TimeClock />', () => {
356
356
/> ,
357
357
) ;
358
358
359
- fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchmove ' , clockTouchEvent [ '--:20' ] ) ;
359
+ fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchstart ' , clockTouchEvent [ '--:20' ] ) ;
360
360
361
361
expect ( handleChange . callCount ) . to . equal ( 0 ) ;
362
362
} ) ;
@@ -374,7 +374,7 @@ describe('<TimeClock />', () => {
374
374
/> ,
375
375
) ;
376
376
377
- fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchmove ' , clockTouchEvent [ '20 :--' ] ) ;
377
+ fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchstart ' , clockTouchEvent [ '19 :--' ] ) ;
378
378
379
379
expect ( handleChange . callCount ) . to . equal ( 0 ) ;
380
380
} ) ;
@@ -392,7 +392,7 @@ describe('<TimeClock />', () => {
392
392
/> ,
393
393
) ;
394
394
395
- fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchmove ' , clockTouchEvent [ '20 :--' ] ) ;
395
+ fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchstart ' , clockTouchEvent [ '19 :--' ] ) ;
396
396
397
397
expect ( handleChange . callCount ) . to . equal ( 0 ) ;
398
398
} ) ;
@@ -427,7 +427,7 @@ describe('<TimeClock />', () => {
427
427
/> ,
428
428
) ;
429
429
430
- fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchmove ' , clockTouchEvent [ '--:10' ] ) ;
430
+ fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchstart ' , clockTouchEvent [ '--:10' ] ) ;
431
431
432
432
expect ( handleChange . callCount ) . to . equal ( 1 ) ;
433
433
const [ date , selectionState ] = handleChange . firstCall . args ;
@@ -449,7 +449,7 @@ describe('<TimeClock />', () => {
449
449
/> ,
450
450
) ;
451
451
452
- fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchmove ' , clockTouchEvent [ '--:20' ] ) ;
452
+ fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchstart ' , clockTouchEvent [ '--:20' ] ) ;
453
453
454
454
expect ( handleChange . callCount ) . to . equal ( 0 ) ;
455
455
} ) ;
@@ -467,10 +467,54 @@ describe('<TimeClock />', () => {
467
467
/> ,
468
468
) ;
469
469
470
- fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchmove ' , clockTouchEvent [ '--:20' ] ) ;
470
+ fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchstart ' , clockTouchEvent [ '--:20' ] ) ;
471
471
472
472
expect ( handleChange . callCount ) . to . equal ( 0 ) ;
473
473
} ) ;
474
+
475
+ it ( 'should select enabled hour on touch and drag' , ( ) => {
476
+ const handleChange = spy ( ) ;
477
+ const handleViewChange = spy ( ) ;
478
+ render (
479
+ < TimeClock
480
+ ampm = { false }
481
+ value = { adapterToUse . date ( '2018-01-01' ) }
482
+ onChange = { handleChange }
483
+ onViewChange = { handleViewChange }
484
+ /> ,
485
+ ) ;
486
+
487
+ fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchstart' , clockTouchEvent [ '13:--' ] ) ;
488
+ fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchmove' , clockTouchEvent [ '19:--' ] ) ;
489
+
490
+ expect ( handleChange . callCount ) . to . equal ( 2 ) ;
491
+ const [ date , selectionState ] = handleChange . lastCall . args ;
492
+ expect ( date ) . toEqualDateTime ( new Date ( 2018 , 0 , 1 , 19 ) ) ;
493
+ expect ( selectionState ) . to . equal ( 'shallow' ) ;
494
+ expect ( handleViewChange . callCount ) . to . equal ( 0 ) ;
495
+ } ) ;
496
+
497
+ it ( 'should select enabled hour and move to next view on touch end' , ( ) => {
498
+ const handleChange = spy ( ) ;
499
+ const handleViewChange = spy ( ) ;
500
+ render (
501
+ < TimeClock
502
+ ampm = { false }
503
+ value = { adapterToUse . date ( '2018-01-01' ) }
504
+ onChange = { handleChange }
505
+ onViewChange = { handleViewChange }
506
+ /> ,
507
+ ) ;
508
+
509
+ fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchstart' , clockTouchEvent [ '13:--' ] ) ;
510
+ fireTouchChangedEvent ( screen . getByMuiTest ( 'clock' ) , 'touchend' , clockTouchEvent [ '13:--' ] ) ;
511
+
512
+ expect ( handleChange . callCount ) . to . equal ( 2 ) ;
513
+ const [ date , selectionState ] = handleChange . lastCall . args ;
514
+ expect ( date ) . toEqualDateTime ( new Date ( 2018 , 0 , 1 , 13 ) ) ;
515
+ expect ( selectionState ) . to . equal ( 'partial' ) ;
516
+ expect ( handleViewChange . callCount ) . to . equal ( 1 ) ;
517
+ } ) ;
474
518
} ) ;
475
519
476
520
describe ( 'default value' , ( ) => {
0 commit comments