@@ -72,4 +72,33 @@ describe('SyntheticEvent', function() {
72
72
expect ( syntheticEvent . isPersistent ( ) ) . toBe ( true ) ;
73
73
} ) ;
74
74
75
+ it ( 'should warn if the Synthetic event has been released when calling `preventDefault`' , function ( ) {
76
+ spyOn ( console , 'error' ) ;
77
+ var syntheticEvent = createEvent ( { } ) ;
78
+ SyntheticEvent . release ( syntheticEvent ) ;
79
+ syntheticEvent . preventDefault ( ) ;
80
+ expect ( console . error . calls . length ) . toBe ( 1 ) ;
81
+ expect ( console . error . argsForCall [ 0 ] [ 0 ] ) . toBe (
82
+ 'Warning: ' +
83
+ 'This Synthetic event is reused for performance reasons. If you\'re seeing this, ' +
84
+ 'you\'re calling `preventDefault` on a released/nullified Synthetic event. ' +
85
+ 'This is a no-op. See https://facebook.github.io/react/docs/events.html#event-pooling ' +
86
+ 'for more information.'
87
+ ) ;
88
+ } ) ;
89
+
90
+ it ( 'should warn if the Synthetic event has been released when calling `stopPropagation`' , function ( ) {
91
+ spyOn ( console , 'error' ) ;
92
+ var syntheticEvent = createEvent ( { } ) ;
93
+ SyntheticEvent . release ( syntheticEvent ) ;
94
+ syntheticEvent . stopPropagation ( ) ;
95
+ expect ( console . error . calls . length ) . toBe ( 1 ) ;
96
+ expect ( console . error . argsForCall [ 0 ] [ 0 ] ) . toBe (
97
+ 'Warning: ' +
98
+ 'This Synthetic event is reused for performance reasons. If you\'re seeing this, ' +
99
+ 'you\'re calling `stopPropagation` on a released/nullified Synthetic event. ' +
100
+ 'This is a no-op. See https://facebook.github.io/react/docs/events.html#event-pooling ' +
101
+ 'for more information.'
102
+ ) ;
103
+ } ) ;
75
104
} ) ;
0 commit comments