Skip to content

Commit

Permalink
fix: invalid touch event
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jan 21, 2020
1 parent 8ce5c9d commit 6b0fbb5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/material-ui/src/StepButton/StepButton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ describe('<StepButton />', () => {
});

describe('event handlers', () => {
it('should forward mouseenter, mouseleave and touchstart', () => {
it('should forward mouseenter, mouseleave and touchstart', function touchTests() {
if (typeof Touch === 'undefined') {
this.skip();
}

const handleMouseEnter = spy();
const handleMouseLeave = spy();
const handleTouchStart = spy();
Expand Down Expand Up @@ -101,14 +105,16 @@ describe('<StepButton />', () => {
expect(handleTouchStart).to.have.property('callCount', 0);

// fake touch
fireEvent.touchStart(button, { touches: [{}] });
const firstTouch = new Touch({ identifier: 0, target: button });
fireEvent.touchStart(button, { touches: [firstTouch] });

expect(handleMouseEnter).to.have.property('callCount', 1);
expect(handleMouseLeave).to.have.property('callCount', 1);
expect(handleTouchStart).to.have.property('callCount', 1);

fireEvent.mouseOver(button);
fireEvent.touchStart(button, { touches: [{}] });
const secondTouch = new Touch({ identifier: 1, target: button });
fireEvent.touchStart(button, { touches: [firstTouch, secondTouch] });

expect(handleMouseEnter).to.have.property('callCount', 2);
expect(handleMouseLeave).to.have.property('callCount', 1);
Expand Down

0 comments on commit 6b0fbb5

Please sign in to comment.