Skip to content

Commit

Permalink
warn(SyntheticEvent): Update tests to check for warning when accessin…
Browse files Browse the repository at this point in the history
…g properties on a destructored syntheticEvent
  • Loading branch information
Kent C. Dodds committed Jan 29, 2016
1 parent 9c3f595 commit 024c001
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ describe('SyntheticEvent', function() {
expect(syntheticEvent.target).toBe(null);
});

it('should warn when accessing properties of a destructored synthetic event', function() {
var target = document.createElement('div');
var syntheticEvent = createEvent({srcElement: target});
syntheticEvent.destructor();
expect(syntheticEvent.type).toBe(null);
expect(console.error.calls.length).toBe(1);
expect(console.error.argsForCall[0][0]).toBe(
'Warning: This synthetic event is reused for performance reasons. If ' +
'you\'re seeing this, you\'re accessing a propertie on a ' +
'released/nullified synthetic event. This is set to null. See ' +
'https://fb.me/react-event-pooling for more information.'
);
});

it('should warn if the synthetic event has been released when calling `preventDefault`', function() {
spyOn(console, 'error');
var syntheticEvent = createEvent({});
Expand Down

0 comments on commit 024c001

Please sign in to comment.