File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -66,3 +66,38 @@ test('blocking swipe on scroll', () => {
66
66
swipeLeftMouse ( listItem ) ;
67
67
expect ( callbackLeft ) . toHaveBeenCalledTimes ( 2 ) ;
68
68
} ) ;
69
+
70
+ test ( 'blocking swipe on scrollElement scroll' , ( ) => {
71
+ const callbackLeft = jest . fn ( ) ;
72
+
73
+ const { queryAllByTestId } = render (
74
+ < SwipeableList scrollElement = { window . document } >
75
+ < SwipeableListItem
76
+ swipeLeft = { {
77
+ content : < span > Left swipe content</ span > ,
78
+ action : callbackLeft
79
+ } }
80
+ >
81
+ < span > Item content 1</ span >
82
+ </ SwipeableListItem >
83
+ </ SwipeableList >
84
+ ) ;
85
+
86
+ const listItem = queryAllByTestId ( 'content' ) [ 0 ] ;
87
+
88
+ // try to swipe - should work
89
+ swipeLeftMouse ( listItem ) ;
90
+ expect ( callbackLeft ) . toHaveBeenCalledTimes ( 1 ) ;
91
+
92
+ fireEvent . scroll ( window . document , { target : { scrollY : 100 } } ) ;
93
+
94
+ // block swipe should be on
95
+ swipeLeftMouse ( listItem ) ;
96
+ expect ( callbackLeft ) . toHaveBeenCalledTimes ( 1 ) ;
97
+
98
+ fireEvent . mouseUp ( window . document ) ;
99
+
100
+ // swiping should be possible again
101
+ swipeLeftMouse ( listItem ) ;
102
+ expect ( callbackLeft ) . toHaveBeenCalledTimes ( 2 ) ;
103
+ } ) ;
You can’t perform that action at this time.
0 commit comments