mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #6380 from zpao/simulatewarning
Make sure simulated events don't warn when providing extra event properties
This commit is contained in:
commit
65c68b5a04
3 files changed
+30
-1
No files matched your search
@@ -144,7 +144,10 @@ describe('SyntheticEvent', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('should properly log warnings when events simulated with rendered components', function() {
|
||||
// TODO: reenable this test. We are currently silencing these warnings when
|
||||
// using TestUtils.Simulate to avoid spurious warnings that result from the
|
||||
// way we simulate events.
|
||||
xit('should properly log warnings when events simulated with rendered components', function() {
|
||||
spyOn(console, 'error');
|
||||
var event;
|
||||
var element = document.createElement('div');
|
||||
|
||||
@@ -498,6 +498,9 @@ function makeSimulator(eventType) {
|
||||
fakeNativeEvent,
|
||||
node
|
||||
);
|
||||
// Since we aren't using pooling, always persist the event. This will make
|
||||
// sure it's marked and won't warn when setting additional properties.
|
||||
event.persist();
|
||||
Object.assign(event, eventData);
|
||||
|
||||
if (dispatchConfig.phasedRegistrationNames) {
|
||||
|
||||
@@ -474,6 +474,29 @@ describe('ReactTestUtils', function() {
|
||||
expect(handler).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not warn when simulating events with extra properties', function() {
|
||||
spyOn(console, 'error');
|
||||
|
||||
var CLIENT_X = 100;
|
||||
|
||||
var Component = React.createClass({
|
||||
handleClick: function(e) {
|
||||
expect(e.clientX).toBe(CLIENT_X);
|
||||
},
|
||||
render: function() {
|
||||
return <div onClick={this.handleClick} />;
|
||||
},
|
||||
});
|
||||
|
||||
var element = document.createElement('div');
|
||||
var instance = ReactDOM.render(<Component />, element);
|
||||
ReactTestUtils.Simulate.click(
|
||||
ReactDOM.findDOMNode(instance),
|
||||
{clientX: CLIENT_X}
|
||||
);
|
||||
expect(console.error.calls.length).toBe(0);
|
||||
});
|
||||
|
||||
it('can scry with stateless components involved', function() {
|
||||
var Stateless = () => <div><hr /></div>;
|
||||
var SomeComponent = React.createClass({
|
||||
|
||||
Reference in new issue
Block a user