{}}
open={false}
PaperProps={{ component: FakePaper }}
+ SwipeAreaProps={{ 'data-testid': 'swipearea' }}
>
Drawer1
@@ -540,47 +523,55 @@ describe('
', () => {
onClose={() => {}}
open={false}
PaperProps={{ component: FakePaper }}
+ SwipeAreaProps={{ 'data-testid': 'swipearea' }}
>
Drawer2
,
);
- // use the same event object for both touch start events, one would propagate to the other swipe area in the browser
- const touchStartEvent = fireSwipeAreaMouseEvent(
- wrapper.find(SwipeableDrawer).at(0),
- 'touchstart',
- {
- touches: [{ pageX: 0, clientY: 0 }],
- },
- );
- wrapper
- .find(SwipeableDrawer)
- .at(1)
- .find(SwipeArea)
- .getDOMNode()
- .dispatchEvent(touchStartEvent);
- fireBodyMouseEvent('touchmove', { touches: [{ pageX: 20, clientY: 0 }] });
- fireBodyMouseEvent('touchmove', { touches: [{ pageX: 180, clientY: 0 }] });
- fireBodyMouseEvent('touchend', { changedTouches: [{ pageX: 180, clientY: 0 }] });
+ // Event order recorded with https://codesandbox.io/s/single-swipearea-lock-ksyss
+ const topMostSwipeArea = screen.getAllByTestId('swipearea').slice(-1)[0];
+ fireEvent.touchStart(topMostSwipeArea, {
+ touches: [new Touch({ identifier: 0, target: topMostSwipeArea, pageX: 0, clientY: 0 })],
+ });
+ fireEvent.touchMove(topMostSwipeArea, {
+ touches: [new Touch({ identifier: 0, target: topMostSwipeArea, pageX: 20, clientY: 0 })],
+ });
+ fireEvent.touchMove(topMostSwipeArea, {
+ touches: [new Touch({ identifier: 0, target: topMostSwipeArea, pageX: 180, clientY: 0 })],
+ });
+ fireEvent.touchEnd(topMostSwipeArea, {
+ changedTouches: [
+ new Touch({ identifier: 0, target: topMostSwipeArea, pageX: 180, clientY: 0 }),
+ ],
+ });
+
expect(handleOpen.callCount).to.equal(1);
});
});
it('does not crash when updating the parent component while swiping', () => {
- const wrapper = mount(
+ render(