From 8e711462ca5e5f0f2ec8701762a35762e43d3c2c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 11 Apr 2016 23:58:14 -0700 Subject: [PATCH] Add `dblclick` to properly map the native event. Fixes #310. --- src/Utils.js | 3 ++- test/ReactWrapper-spec.js | 7 +++++-- test/ShallowWrapper-spec.js | 8 ++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Utils.js b/src/Utils.js index e5d017932..001c37ad6 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -227,7 +227,8 @@ export function mapNativeEventNames(event) { keyup: 'keyUp', keypress: 'keyPress', contextmenu: 'contextMenu', - doubleclick: 'doubleClick', + dblclick: 'doubleClick', + doubleclick: 'doubleClick', // kept for legacy. TODO: remove with next major. dragend: 'dragEnd', dragenter: 'dragEnter', dragexist: 'dragExit', diff --git a/test/ReactWrapper-spec.js b/test/ReactWrapper-spec.js index e29519ff0..3248d7c3e 100644 --- a/test/ReactWrapper-spec.js +++ b/test/ReactWrapper-spec.js @@ -813,18 +813,21 @@ describeWithDOM('mount', () => { describe('Normalizing JS event names', () => { it('should convert lowercase events to React camelcase', () => { const spy = sinon.spy(); + const clickSpy = sinon.spy(); class Foo extends React.Component { render() { return ( - foo + foo ); } } const wrapper = mount(); - wrapper.simulate('doubleclick'); + wrapper.simulate('dblclick'); expect(spy.calledOnce).to.equal(true); + wrapper.simulate('click'); + expect(clickSpy.calledOnce).to.equal(true); }); describeIf(!REACT013, 'normalizing mouseenter', () => { diff --git a/test/ShallowWrapper-spec.js b/test/ShallowWrapper-spec.js index 7c9be4b20..d63901583 100644 --- a/test/ShallowWrapper-spec.js +++ b/test/ShallowWrapper-spec.js @@ -919,18 +919,22 @@ describe('shallow', () => { describe('Normalizing JS event names', () => { it('should convert lowercase events to React camelcase', () => { const spy = sinon.spy(); + const clickSpy = sinon.spy(); class Foo extends React.Component { render() { return ( - foo + foo ); } } const wrapper = shallow(); - wrapper.simulate('doubleclick'); + wrapper.simulate('dblclick'); expect(spy.calledOnce).to.equal(true); + + wrapper.simulate('click'); + expect(clickSpy.calledOnce).to.equal(true); }); describeIf(!REACT013, 'normalizing mouseenter', () => {