@samitouri / QOS-React / commits / 5f6f3277f5

Add test for hack to stop bubbling (#8922)

Ben Alpert committed Feb 22, 2017 at 14:02 UTC 5f6f3277f5ada837fd6096b8ad330f4914ae6200
2 files changed +28
scripts/fiber/tests-passing.txt
+1
@@ -964,6 +964,7 @@ src/renderers/dom/shared/__tests__/ReactBrowserEventEmitter-test.js
964 * should continue bubbling if an error is thrown
965 * should set currentTarget
966 * should support stopPropagation()
967 +* should support overriding .isPropagationStopped()
968 * should stop after first dispatch if stopPropagation
969 * should not stopPropagation if false is returned
970 * should invoke handlers that were removed while bubbling
src/renderers/dom/shared/__tests__/ReactBrowserEventEmitter-test.js
+27
@@ -325,6 +325,33 @@ describe('ReactBrowserEventEmitter', () => {
325 expect(idCallOrder[1]).toBe(PARENT);
326 });
327
328 + it('should support overriding .isPropagationStopped()', () => {
329 + // Ew. See D4504876.
330 + putListener(
331 + CHILD,
332 + ON_CLICK_KEY,
333 + recordID.bind(null, CHILD)
334 + );
335 + putListener(
336 + PARENT,
337 + ON_CLICK_KEY,
338 + function(e) {
339 + recordID(PARENT, e);
340 + // This stops React bubbling but avoids touching the native event
341 + e.isPropagationStopped = () => true;
342 + }
343 + );
344 + putListener(
345 + GRANDPARENT,
346 + ON_CLICK_KEY,
347 + recordID.bind(null, GRANDPARENT)
348 + );
349 + ReactTestUtils.Simulate.click(CHILD);
350 + expect(idCallOrder.length).toBe(2);
351 + expect(idCallOrder[0]).toBe(CHILD);
352 + expect(idCallOrder[1]).toBe(PARENT);
353 + });
354 +
355 it('should stop after first dispatch if stopPropagation', () => {
356 putListener(
357 CHILD,