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 248cbc4 commit 8e7e170
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 @@ -188,6 +188,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 @@ -2091,6 +2091,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 @@ -2012,6 +2012,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 8e7e170

Please sign in to comment.