@@ -493,3 +493,53 @@ test('has only onMove', () => {
493
493
} ) ;
494
494
expect ( handleDrag ) . toHaveBeenCalled ( ) ;
495
495
} ) ;
496
+
497
+ // Those events ideally should be triggered through `fireEvent.scroll`, but they are handled at the
498
+ // native level, so we need to support manually triggering them
499
+ describe ( 'native events' , ( ) => {
500
+ test ( 'triggers onScrollBeginDrag' , ( ) => {
501
+ const onScrollBeginDragSpy = jest . fn ( ) ;
502
+ const { getByTestId } = render (
503
+ < ScrollView testID = "test-id" onScrollBeginDrag = { onScrollBeginDragSpy } />
504
+ ) ;
505
+
506
+ fireEvent ( getByTestId ( 'test-id' ) , 'onScrollBeginDrag' ) ;
507
+ expect ( onScrollBeginDragSpy ) . toHaveBeenCalled ( ) ;
508
+ } ) ;
509
+
510
+ test ( 'triggers onScrollEndDrag' , ( ) => {
511
+ const onScrollEndDragSpy = jest . fn ( ) ;
512
+ const { getByTestId } = render (
513
+ < ScrollView testID = "test-id" onScrollEndDrag = { onScrollEndDragSpy } />
514
+ ) ;
515
+
516
+ fireEvent ( getByTestId ( 'test-id' ) , 'onScrollEndDrag' ) ;
517
+ expect ( onScrollEndDragSpy ) . toHaveBeenCalled ( ) ;
518
+ } ) ;
519
+
520
+ test ( 'triggers onMomentumScrollBegin' , ( ) => {
521
+ const onMomentumScrollBeginSpy = jest . fn ( ) ;
522
+ const { getByTestId } = render (
523
+ < ScrollView
524
+ testID = "test-id"
525
+ onMomentumScrollBegin = { onMomentumScrollBeginSpy }
526
+ />
527
+ ) ;
528
+
529
+ fireEvent ( getByTestId ( 'test-id' ) , 'onMomentumScrollBegin' ) ;
530
+ expect ( onMomentumScrollBeginSpy ) . toHaveBeenCalled ( ) ;
531
+ } ) ;
532
+
533
+ test ( 'triggers onMomentumScrollEnd' , ( ) => {
534
+ const onMomentumScrollEndSpy = jest . fn ( ) ;
535
+ const { getByTestId } = render (
536
+ < ScrollView
537
+ testID = "test-id"
538
+ onMomentumScrollEnd = { onMomentumScrollEndSpy }
539
+ />
540
+ ) ;
541
+
542
+ fireEvent ( getByTestId ( 'test-id' ) , 'onMomentumScrollEnd' ) ;
543
+ expect ( onMomentumScrollEndSpy ) . toHaveBeenCalled ( ) ;
544
+ } ) ;
545
+ } ) ;
0 commit comments