From 30faaf142d403442fb85a108665af50300da503a Mon Sep 17 00:00:00 2001 From: Nathan Hunzaker Date: Wed, 15 Nov 2017 07:11:03 -0500 Subject: [PATCH] Set correct event type on fake TestUtils events This commit fixes an issue where events generated by the test utils had no type. These events are not real DOM Event objects, and their constructor never assigned the provided event type property. Additionally, it looks like the Event object was being constructed with the top level type (`topClick` vs `click`). This commit ensures that ReactTestUtils.Simulate and ReactTestUtils.SimulateNative correctly assign the event type. --- .../src/__tests__/ReactTestUtils-test.js | 28 +++++++++++++++++++ .../src/test-utils/ReactTestUtils.js | 16 ++++++----- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactTestUtils-test.js b/packages/react-dom/src/__tests__/ReactTestUtils-test.js index a8f1b69f58a12..ff5043020cd08 100644 --- a/packages/react-dom/src/__tests__/ReactTestUtils-test.js +++ b/packages/react-dom/src/__tests__/ReactTestUtils-test.js @@ -429,6 +429,34 @@ describe('ReactTestUtils', () => { jasmine.objectContaining({target: input}), ); }); + + it('should set the correct event type when simulating synthetic events', () => { + expect.assertions(1); + + let handler = function(event) { + expect(event.nativeEvent.type).toEqual('click'); + }; + + let button = ReactTestUtils.renderIntoDocument( +