Skip to content

Commit

Permalink
[enzyme-adapter-react-16] [new] add pointer events support
Browse files Browse the repository at this point in the history
Fixes 1719.
  • Loading branch information
ljharb committed Aug 15, 2018
1 parent de7984a commit a3ee0fe
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ function nodeToHostNode(_node) {

const eventOptions = {
animation: true,
pointerEvents: true, // 16.4+
};

class ReactSixteenAdapter extends EnzymeAdapter {
Expand Down
30 changes: 30 additions & 0 deletions packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2038,6 +2038,36 @@ describeWithDOM('mount', () => {
expect(spy).to.have.property('callCount', 1);
});
});

describeIf(is('>= 16.4'), 'pointer events', () => {
it('should convert lowercase events to React camelcase', () => {
const spy = sinon.spy();
class Foo extends React.Component {
render() {
return (
<a onGotPointerCapture={spy}>foo</a>
);
}
}

const wrapper = mount(<Foo />);

wrapper.simulate('gotpointercapture');
expect(spy).to.have.property('callCount', 1);
});

it('should convert lowercase events to React camelcase in stateless components', () => {
const spy = sinon.spy();
const Foo = () => (
<a onGotPointerCapture={spy}>foo</a>
);

const wrapper = mount(<Foo />);

wrapper.simulate('gotpointercapture');
expect(spy).to.have.property('callCount', 1);
});
});
});

it('should be batched updates', () => {
Expand Down
30 changes: 30 additions & 0 deletions packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,36 @@ describe('shallow', () => {
expect(spy).to.have.property('callCount', 1);
});
});

describeIf(is('>= 16.4'), 'pointer events', () => {
it('should convert lowercase events to React camelcase', () => {
const spy = sinon.spy();
class Foo extends React.Component {
render() {
return (
<a onGotPointerCapture={spy}>foo</a>
);
}
}

const wrapper = shallow(<Foo />);

wrapper.simulate('gotpointercapture');
expect(spy).to.have.property('callCount', 1);
});

it('should convert lowercase events to React camelcase in stateless components', () => {
const spy = sinon.spy();
const Foo = () => (
<a onGotPointerCapture={spy}>foo</a>
);

const wrapper = shallow(<Foo />);

wrapper.simulate('gotpointercapture');
expect(spy).to.have.property('callCount', 1);
});
});
});

itIf(BATCHING, 'should be batched updates', () => {
Expand Down

0 comments on commit a3ee0fe

Please sign in to comment.