Skip to content

Commit

Permalink
Add failing test for multi-touch behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jan 21, 2020
1 parent c29c8ad commit a0f6255
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/material-ui/src/ButtonBase/TouchRipple.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('<TouchRipple />', () => {
*/
function renderTouchRipple(other) {
const touchRippleRef = React.createRef();
const { container } = render(
const { container, unmount } = render(
<TouchRipple
ref={touchRippleRef}
classes={{
Expand All @@ -42,6 +42,7 @@ describe('<TouchRipple />', () => {
queryRipple() {
return container.querySelector('.ripple');
},
unmount,
};
}

Expand Down Expand Up @@ -155,6 +156,9 @@ describe('<TouchRipple />', () => {
});

describe('mobile', () => {
/**
* @type {ReturnType<typeof useFakeTimers>}
*/
let clock;

before(() => {
Expand Down Expand Up @@ -227,5 +231,17 @@ describe('<TouchRipple />', () => {
expect(queryAllActiveRipples()).to.have.lengthOf(0);
expect(queryAllStoppingRipples()).to.have.lengthOf(0);
});

it('should not leak on multi-touch', function multiTouchTest() {
const { instance, unmount } = renderTouchRipple();

instance.start({ type: 'touchstart', touches: [{}] }, () => {});
instance.start({ type: 'touchstart', touches: [{}] }, () => {});
unmount();

// expect this to run gracefully without
// "react state update on an unmounted component"
clock.runAll();
});
});
});

0 comments on commit a0f6255

Please sign in to comment.