UNPKG

45.9 kBJavaScriptView Raw
1/** @license React v16.7.0
2 * react-dom-test-utils.development.js
3 *
4 * Copyright (c) Facebook, Inc. and its affiliates.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9
10'use strict';
11
12(function (global, factory) {
13 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('react-dom')) :
14 typeof define === 'function' && define.amd ? define(['react', 'react-dom'], factory) :
15 (global.ReactTestUtils = factory(global.React,global.ReactDOM));
16}(this, (function (React,ReactDOM) { 'use strict';
17
18var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
19
20var _assign = ReactInternals.assign;
21
22/**
23 * Use invariant() to assert state which your program assumes to be true.
24 *
25 * Provide sprintf-style format (only %s is supported) and arguments
26 * to provide information about what broke and what you were
27 * expecting.
28 *
29 * The invariant message will be stripped in production, but the invariant
30 * will remain to ensure logic does not differ in production.
31 */
32
33var validateFormat = function () {};
34
35{
36 validateFormat = function (format) {
37 if (format === undefined) {
38 throw new Error('invariant requires an error message argument');
39 }
40 };
41}
42
43function invariant(condition, format, a, b, c, d, e, f) {
44 validateFormat(format);
45
46 if (!condition) {
47 var error = void 0;
48 if (format === undefined) {
49 error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
50 } else {
51 var args = [a, b, c, d, e, f];
52 var argIndex = 0;
53 error = new Error(format.replace(/%s/g, function () {
54 return args[argIndex++];
55 }));
56 error.name = 'Invariant Violation';
57 }
58
59 error.framesToPop = 1; // we don't care about invariant's own frame
60 throw error;
61 }
62}
63
64// Relying on the `invariant()` implementation lets us
65// preserve the format and params in the www builds.
66
67/**
68 * Similar to invariant but only logs a warning if the condition is not met.
69 * This can be used to log issues in development environments in critical
70 * paths. Removing the logging code for production environments will keep the
71 * same logic and follow the same code paths.
72 */
73
74var warningWithoutStack = function () {};
75
76{
77 warningWithoutStack = function (condition, format) {
78 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
79 args[_key - 2] = arguments[_key];
80 }
81
82 if (format === undefined) {
83 throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
84 }
85 if (args.length > 8) {
86 // Check before the condition to catch violations early.
87 throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
88 }
89 if (condition) {
90 return;
91 }
92 if (typeof console !== 'undefined') {
93 var argsWithFormat = args.map(function (item) {
94 return '' + item;
95 });
96 argsWithFormat.unshift('Warning: ' + format);
97
98 // We intentionally don't use spread (or .apply) directly because it
99 // breaks IE9: https://github.com/facebook/react/issues/13610
100 Function.prototype.apply.call(console.error, console, argsWithFormat);
101 }
102 try {
103 // --- Welcome to debugging React ---
104 // This error was thrown as a convenience so that you can use this stack
105 // to find the callsite that caused this warning to fire.
106 var argIndex = 0;
107 var message = 'Warning: ' + format.replace(/%s/g, function () {
108 return args[argIndex++];
109 });
110 throw new Error(message);
111 } catch (x) {}
112 };
113}
114
115var warningWithoutStack$1 = warningWithoutStack;
116
117/**
118 * `ReactInstanceMap` maintains a mapping from a public facing stateful
119 * instance (key) and the internal representation (value). This allows public
120 * methods to accept the user facing instance as an argument and map them back
121 * to internal methods.
122 *
123 * Note that this module is currently shared and assumed to be stateless.
124 * If this becomes an actual Map, that will break.
125 */
126
127/**
128 * This API should be called `delete` but we'd have to make sure to always
129 * transform these to strings for IE support. When this transform is fully
130 * supported we can rename it.
131 */
132
133
134function get(key) {
135 return key._reactInternalFiber;
136}
137
138var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
139
140// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
141// nor polyfill, then a plain number is used for performance.
142
143var FunctionComponent = 0;
144var ClassComponent = 1;
145 // Before we know whether it is function or class
146var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
147 // A subtree. Could be an entry point to a different renderer.
148var HostComponent = 5;
149var HostText = 6;
150
151// Don't change these two values. They're used by React Dev Tools.
152var NoEffect = /* */0;
153
154
155// You can change the rest (and add more).
156var Placement = /* */2;
157
158
159
160
161
162
163
164
165
166
167// Passive & Update & Callback & Ref & Snapshot
168
169
170// Union of all host effects
171
172var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
173
174var MOUNTING = 1;
175var MOUNTED = 2;
176var UNMOUNTED = 3;
177
178function isFiberMountedImpl(fiber) {
179 var node = fiber;
180 if (!fiber.alternate) {
181 // If there is no alternate, this might be a new tree that isn't inserted
182 // yet. If it is, then it will have a pending insertion effect on it.
183 if ((node.effectTag & Placement) !== NoEffect) {
184 return MOUNTING;
185 }
186 while (node.return) {
187 node = node.return;
188 if ((node.effectTag & Placement) !== NoEffect) {
189 return MOUNTING;
190 }
191 }
192 } else {
193 while (node.return) {
194 node = node.return;
195 }
196 }
197 if (node.tag === HostRoot) {
198 // TODO: Check if this was a nested HostRoot when used with
199 // renderContainerIntoSubtree.
200 return MOUNTED;
201 }
202 // If we didn't hit the root, that means that we're in an disconnected tree
203 // that has been unmounted.
204 return UNMOUNTED;
205}
206
207
208
209
210
211function assertIsMounted(fiber) {
212 !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
213}
214
215function findCurrentFiberUsingSlowPath(fiber) {
216 var alternate = fiber.alternate;
217 if (!alternate) {
218 // If there is no alternate, then we only need to check if it is mounted.
219 var state = isFiberMountedImpl(fiber);
220 !(state !== UNMOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
221 if (state === MOUNTING) {
222 return null;
223 }
224 return fiber;
225 }
226 // If we have two possible branches, we'll walk backwards up to the root
227 // to see what path the root points to. On the way we may hit one of the
228 // special cases and we'll deal with them.
229 var a = fiber;
230 var b = alternate;
231 while (true) {
232 var parentA = a.return;
233 var parentB = parentA ? parentA.alternate : null;
234 if (!parentA || !parentB) {
235 // We're at the root.
236 break;
237 }
238
239 // If both copies of the parent fiber point to the same child, we can
240 // assume that the child is current. This happens when we bailout on low
241 // priority: the bailed out fiber's child reuses the current child.
242 if (parentA.child === parentB.child) {
243 var child = parentA.child;
244 while (child) {
245 if (child === a) {
246 // We've determined that A is the current branch.
247 assertIsMounted(parentA);
248 return fiber;
249 }
250 if (child === b) {
251 // We've determined that B is the current branch.
252 assertIsMounted(parentA);
253 return alternate;
254 }
255 child = child.sibling;
256 }
257 // We should never have an alternate for any mounting node. So the only
258 // way this could possibly happen is if this was unmounted, if at all.
259 invariant(false, 'Unable to find node on an unmounted component.');
260 }
261
262 if (a.return !== b.return) {
263 // The return pointer of A and the return pointer of B point to different
264 // fibers. We assume that return pointers never criss-cross, so A must
265 // belong to the child set of A.return, and B must belong to the child
266 // set of B.return.
267 a = parentA;
268 b = parentB;
269 } else {
270 // The return pointers point to the same fiber. We'll have to use the
271 // default, slow path: scan the child sets of each parent alternate to see
272 // which child belongs to which set.
273 //
274 // Search parent A's child set
275 var didFindChild = false;
276 var _child = parentA.child;
277 while (_child) {
278 if (_child === a) {
279 didFindChild = true;
280 a = parentA;
281 b = parentB;
282 break;
283 }
284 if (_child === b) {
285 didFindChild = true;
286 b = parentA;
287 a = parentB;
288 break;
289 }
290 _child = _child.sibling;
291 }
292 if (!didFindChild) {
293 // Search parent B's child set
294 _child = parentB.child;
295 while (_child) {
296 if (_child === a) {
297 didFindChild = true;
298 a = parentB;
299 b = parentA;
300 break;
301 }
302 if (_child === b) {
303 didFindChild = true;
304 b = parentB;
305 a = parentA;
306 break;
307 }
308 _child = _child.sibling;
309 }
310 !didFindChild ? invariant(false, 'Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.') : void 0;
311 }
312 }
313
314 !(a.alternate === b) ? invariant(false, 'Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.') : void 0;
315 }
316 // If the root is not a host container, we're in a disconnected tree. I.e.
317 // unmounted.
318 !(a.tag === HostRoot) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
319 if (a.stateNode.current === a) {
320 // We've determined that A is the current branch.
321 return fiber;
322 }
323 // Otherwise B has to be current branch.
324 return alternate;
325}
326
327/* eslint valid-typeof: 0 */
328
329var EVENT_POOL_SIZE = 10;
330
331/**
332 * @interface Event
333 * @see http://www.w3.org/TR/DOM-Level-3-Events/
334 */
335var EventInterface = {
336 type: null,
337 target: null,
338 // currentTarget is set when dispatching; no use in copying it here
339 currentTarget: function () {
340 return null;
341 },
342 eventPhase: null,
343 bubbles: null,
344 cancelable: null,
345 timeStamp: function (event) {
346 return event.timeStamp || Date.now();
347 },
348 defaultPrevented: null,
349 isTrusted: null
350};
351
352function functionThatReturnsTrue() {
353 return true;
354}
355
356function functionThatReturnsFalse() {
357 return false;
358}
359
360/**
361 * Synthetic events are dispatched by event plugins, typically in response to a
362 * top-level event delegation handler.
363 *
364 * These systems should generally use pooling to reduce the frequency of garbage
365 * collection. The system should check `isPersistent` to determine whether the
366 * event should be released into the pool after being dispatched. Users that
367 * need a persisted event should invoke `persist`.
368 *
369 * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
370 * normalizing browser quirks. Subclasses do not necessarily have to implement a
371 * DOM interface; custom application-specific events can also subclass this.
372 *
373 * @param {object} dispatchConfig Configuration used to dispatch this event.
374 * @param {*} targetInst Marker identifying the event target.
375 * @param {object} nativeEvent Native browser event.
376 * @param {DOMEventTarget} nativeEventTarget Target node.
377 */
378function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
379 {
380 // these have a getter/setter for warnings
381 delete this.nativeEvent;
382 delete this.preventDefault;
383 delete this.stopPropagation;
384 delete this.isDefaultPrevented;
385 delete this.isPropagationStopped;
386 }
387
388 this.dispatchConfig = dispatchConfig;
389 this._targetInst = targetInst;
390 this.nativeEvent = nativeEvent;
391
392 var Interface = this.constructor.Interface;
393 for (var propName in Interface) {
394 if (!Interface.hasOwnProperty(propName)) {
395 continue;
396 }
397 {
398 delete this[propName]; // this has a getter/setter for warnings
399 }
400 var normalize = Interface[propName];
401 if (normalize) {
402 this[propName] = normalize(nativeEvent);
403 } else {
404 if (propName === 'target') {
405 this.target = nativeEventTarget;
406 } else {
407 this[propName] = nativeEvent[propName];
408 }
409 }
410 }
411
412 var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
413 if (defaultPrevented) {
414 this.isDefaultPrevented = functionThatReturnsTrue;
415 } else {
416 this.isDefaultPrevented = functionThatReturnsFalse;
417 }
418 this.isPropagationStopped = functionThatReturnsFalse;
419 return this;
420}
421
422_assign(SyntheticEvent.prototype, {
423 preventDefault: function () {
424 this.defaultPrevented = true;
425 var event = this.nativeEvent;
426 if (!event) {
427 return;
428 }
429
430 if (event.preventDefault) {
431 event.preventDefault();
432 } else if (typeof event.returnValue !== 'unknown') {
433 event.returnValue = false;
434 }
435 this.isDefaultPrevented = functionThatReturnsTrue;
436 },
437
438 stopPropagation: function () {
439 var event = this.nativeEvent;
440 if (!event) {
441 return;
442 }
443
444 if (event.stopPropagation) {
445 event.stopPropagation();
446 } else if (typeof event.cancelBubble !== 'unknown') {
447 // The ChangeEventPlugin registers a "propertychange" event for
448 // IE. This event does not support bubbling or cancelling, and
449 // any references to cancelBubble throw "Member not found". A
450 // typeof check of "unknown" circumvents this issue (and is also
451 // IE specific).
452 event.cancelBubble = true;
453 }
454
455 this.isPropagationStopped = functionThatReturnsTrue;
456 },
457
458 /**
459 * We release all dispatched `SyntheticEvent`s after each event loop, adding
460 * them back into the pool. This allows a way to hold onto a reference that
461 * won't be added back into the pool.
462 */
463 persist: function () {
464 this.isPersistent = functionThatReturnsTrue;
465 },
466
467 /**
468 * Checks if this event should be released back into the pool.
469 *
470 * @return {boolean} True if this should not be released, false otherwise.
471 */
472 isPersistent: functionThatReturnsFalse,
473
474 /**
475 * `PooledClass` looks for `destructor` on each instance it releases.
476 */
477 destructor: function () {
478 var Interface = this.constructor.Interface;
479 for (var propName in Interface) {
480 {
481 Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
482 }
483 }
484 this.dispatchConfig = null;
485 this._targetInst = null;
486 this.nativeEvent = null;
487 this.isDefaultPrevented = functionThatReturnsFalse;
488 this.isPropagationStopped = functionThatReturnsFalse;
489 this._dispatchListeners = null;
490 this._dispatchInstances = null;
491 {
492 Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
493 Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
494 Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse));
495 Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {}));
496 Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {}));
497 }
498 }
499});
500
501SyntheticEvent.Interface = EventInterface;
502
503/**
504 * Helper to reduce boilerplate when creating subclasses.
505 */
506SyntheticEvent.extend = function (Interface) {
507 var Super = this;
508
509 var E = function () {};
510 E.prototype = Super.prototype;
511 var prototype = new E();
512
513 function Class() {
514 return Super.apply(this, arguments);
515 }
516 _assign(prototype, Class.prototype);
517 Class.prototype = prototype;
518 Class.prototype.constructor = Class;
519
520 Class.Interface = _assign({}, Super.Interface, Interface);
521 Class.extend = Super.extend;
522 addEventPoolingTo(Class);
523
524 return Class;
525};
526
527addEventPoolingTo(SyntheticEvent);
528
529/**
530 * Helper to nullify syntheticEvent instance properties when destructing
531 *
532 * @param {String} propName
533 * @param {?object} getVal
534 * @return {object} defineProperty object
535 */
536function getPooledWarningPropertyDefinition(propName, getVal) {
537 var isFunction = typeof getVal === 'function';
538 return {
539 configurable: true,
540 set: set,
541 get: get
542 };
543
544 function set(val) {
545 var action = isFunction ? 'setting the method' : 'setting the property';
546 warn(action, 'This is effectively a no-op');
547 return val;
548 }
549
550 function get() {
551 var action = isFunction ? 'accessing the method' : 'accessing the property';
552 var result = isFunction ? 'This is a no-op function' : 'This is set to null';
553 warn(action, result);
554 return getVal;
555 }
556
557 function warn(action, result) {
558 var warningCondition = false;
559 !warningCondition ? warningWithoutStack$1(false, "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result) : void 0;
560 }
561}
562
563function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
564 var EventConstructor = this;
565 if (EventConstructor.eventPool.length) {
566 var instance = EventConstructor.eventPool.pop();
567 EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
568 return instance;
569 }
570 return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst);
571}
572
573function releasePooledEvent(event) {
574 var EventConstructor = this;
575 !(event instanceof EventConstructor) ? invariant(false, 'Trying to release an event instance into a pool of a different type.') : void 0;
576 event.destructor();
577 if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
578 EventConstructor.eventPool.push(event);
579 }
580}
581
582function addEventPoolingTo(EventConstructor) {
583 EventConstructor.eventPool = [];
584 EventConstructor.getPooled = getPooledEvent;
585 EventConstructor.release = releasePooledEvent;
586}
587
588/**
589 * Forked from fbjs/warning:
590 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
591 *
592 * Only change is we use console.warn instead of console.error,
593 * and do nothing when 'console' is not supported.
594 * This really simplifies the code.
595 * ---
596 * Similar to invariant but only logs a warning if the condition is not met.
597 * This can be used to log issues in development environments in critical
598 * paths. Removing the logging code for production environments will keep the
599 * same logic and follow the same code paths.
600 */
601
602var lowPriorityWarning = function () {};
603
604{
605 var printWarning = function (format) {
606 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
607 args[_key - 1] = arguments[_key];
608 }
609
610 var argIndex = 0;
611 var message = 'Warning: ' + format.replace(/%s/g, function () {
612 return args[argIndex++];
613 });
614 if (typeof console !== 'undefined') {
615 console.warn(message);
616 }
617 try {
618 // --- Welcome to debugging React ---
619 // This error was thrown as a convenience so that you can use this stack
620 // to find the callsite that caused this warning to fire.
621 throw new Error(message);
622 } catch (x) {}
623 };
624
625 lowPriorityWarning = function (condition, format) {
626 if (format === undefined) {
627 throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
628 }
629 if (!condition) {
630 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
631 args[_key2 - 2] = arguments[_key2];
632 }
633
634 printWarning.apply(undefined, [format].concat(args));
635 }
636 };
637}
638
639var lowPriorityWarning$1 = lowPriorityWarning;
640
641/**
642 * HTML nodeType values that represent the type of the node
643 */
644
645var ELEMENT_NODE = 1;
646
647// Do not uses the below two methods directly!
648// Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
649// (It is the only module that is allowed to access these methods.)
650
651function unsafeCastStringToDOMTopLevelType(topLevelType) {
652 return topLevelType;
653}
654
655var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
656
657/**
658 * Generate a mapping of standard vendor prefixes using the defined style property and event name.
659 *
660 * @param {string} styleProp
661 * @param {string} eventName
662 * @returns {object}
663 */
664function makePrefixMap(styleProp, eventName) {
665 var prefixes = {};
666
667 prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
668 prefixes['Webkit' + styleProp] = 'webkit' + eventName;
669 prefixes['Moz' + styleProp] = 'moz' + eventName;
670
671 return prefixes;
672}
673
674/**
675 * A list of event names to a configurable list of vendor prefixes.
676 */
677var vendorPrefixes = {
678 animationend: makePrefixMap('Animation', 'AnimationEnd'),
679 animationiteration: makePrefixMap('Animation', 'AnimationIteration'),
680 animationstart: makePrefixMap('Animation', 'AnimationStart'),
681 transitionend: makePrefixMap('Transition', 'TransitionEnd')
682};
683
684/**
685 * Event names that have already been detected and prefixed (if applicable).
686 */
687var prefixedEventNames = {};
688
689/**
690 * Element to check for prefixes on.
691 */
692var style = {};
693
694/**
695 * Bootstrap if a DOM exists.
696 */
697if (canUseDOM) {
698 style = document.createElement('div').style;
699
700 // On some platforms, in particular some releases of Android 4.x,
701 // the un-prefixed "animation" and "transition" properties are defined on the
702 // style object but the events that fire will still be prefixed, so we need
703 // to check if the un-prefixed events are usable, and if not remove them from the map.
704 if (!('AnimationEvent' in window)) {
705 delete vendorPrefixes.animationend.animation;
706 delete vendorPrefixes.animationiteration.animation;
707 delete vendorPrefixes.animationstart.animation;
708 }
709
710 // Same as above
711 if (!('TransitionEvent' in window)) {
712 delete vendorPrefixes.transitionend.transition;
713 }
714}
715
716/**
717 * Attempts to determine the correct vendor prefixed event name.
718 *
719 * @param {string} eventName
720 * @returns {string}
721 */
722function getVendorPrefixedEventName(eventName) {
723 if (prefixedEventNames[eventName]) {
724 return prefixedEventNames[eventName];
725 } else if (!vendorPrefixes[eventName]) {
726 return eventName;
727 }
728
729 var prefixMap = vendorPrefixes[eventName];
730
731 for (var styleProp in prefixMap) {
732 if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) {
733 return prefixedEventNames[eventName] = prefixMap[styleProp];
734 }
735 }
736
737 return eventName;
738}
739
740/**
741 * To identify top level events in ReactDOM, we use constants defined by this
742 * module. This is the only module that uses the unsafe* methods to express
743 * that the constants actually correspond to the browser event names. This lets
744 * us save some bundle size by avoiding a top level type -> event name map.
745 * The rest of ReactDOM code should import top level types from this file.
746 */
747var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
748var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend'));
749var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration'));
750var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart'));
751var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur');
752var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay');
753var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough');
754var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel');
755var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change');
756var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click');
757var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close');
758var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend');
759var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart');
760var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate');
761var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu');
762var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy');
763var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut');
764var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick');
765
766var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag');
767var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend');
768var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter');
769var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit');
770var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave');
771var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover');
772var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart');
773var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop');
774var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange');
775var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied');
776var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted');
777var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended');
778var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error');
779var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus');
780
781var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input');
782
783var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown');
784var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress');
785var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup');
786var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load');
787var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart');
788var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata');
789var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata');
790
791var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown');
792var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove');
793var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout');
794var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover');
795var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup');
796var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste');
797var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause');
798var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play');
799var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing');
800
801
802
803
804
805
806
807
808var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress');
809var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange');
810
811var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll');
812var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked');
813var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking');
814var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange');
815var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled');
816
817var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend');
818var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput');
819var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate');
820var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle');
821var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel');
822var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend');
823var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove');
824var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart');
825var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend'));
826var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange');
827var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting');
828var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel');
829
830// List of events that need to be individually attached to media elements.
831// Note that events in this list will *not* be listened to at the top level
832// unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
833
834var findDOMNode = ReactDOM.findDOMNode;
835// Keep in sync with ReactDOMUnstableNativeDependencies.js
836// and ReactDOM.js:
837
838var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
839var getInstanceFromNode = _ReactDOM$__SECRET_IN[0];
840var getNodeFromInstance = _ReactDOM$__SECRET_IN[1];
841var getFiberCurrentPropsFromNode = _ReactDOM$__SECRET_IN[2];
842var injectEventPluginsByName = _ReactDOM$__SECRET_IN[3];
843var eventNameDispatchConfigs = _ReactDOM$__SECRET_IN[4];
844var accumulateTwoPhaseDispatches = _ReactDOM$__SECRET_IN[5];
845var accumulateDirectDispatches = _ReactDOM$__SECRET_IN[6];
846var enqueueStateRestore = _ReactDOM$__SECRET_IN[7];
847var restoreStateIfNeeded = _ReactDOM$__SECRET_IN[8];
848var dispatchEvent = _ReactDOM$__SECRET_IN[9];
849var runEventsInBatch = _ReactDOM$__SECRET_IN[10];
850
851
852function Event(suffix) {}
853
854var hasWarnedAboutDeprecatedMockComponent = false;
855
856/**
857 * @class ReactTestUtils
858 */
859
860/**
861 * Simulates a top level event being dispatched from a raw event that occurred
862 * on an `Element` node.
863 * @param {number} topLevelType A number from `TopLevelEventTypes`
864 * @param {!Element} node The dom to simulate an event occurring on.
865 * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
866 */
867function simulateNativeEventOnNode(topLevelType, node, fakeNativeEvent) {
868 fakeNativeEvent.target = node;
869 dispatchEvent(topLevelType, fakeNativeEvent);
870}
871
872/**
873 * Simulates a top level event being dispatched from a raw event that occurred
874 * on the `ReactDOMComponent` `comp`.
875 * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes`.
876 * @param {!ReactDOMComponent} comp
877 * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
878 */
879function simulateNativeEventOnDOMComponent(topLevelType, comp, fakeNativeEvent) {
880 simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent);
881}
882
883function findAllInRenderedFiberTreeInternal(fiber, test) {
884 if (!fiber) {
885 return [];
886 }
887 var currentParent = findCurrentFiberUsingSlowPath(fiber);
888 if (!currentParent) {
889 return [];
890 }
891 var node = currentParent;
892 var ret = [];
893 while (true) {
894 if (node.tag === HostComponent || node.tag === HostText || node.tag === ClassComponent || node.tag === FunctionComponent) {
895 var publicInst = node.stateNode;
896 if (test(publicInst)) {
897 ret.push(publicInst);
898 }
899 }
900 if (node.child) {
901 node.child.return = node;
902 node = node.child;
903 continue;
904 }
905 if (node === currentParent) {
906 return ret;
907 }
908 while (!node.sibling) {
909 if (!node.return || node.return === currentParent) {
910 return ret;
911 }
912 node = node.return;
913 }
914 node.sibling.return = node.return;
915 node = node.sibling;
916 }
917}
918
919function validateClassInstance(inst, methodName) {
920 if (!inst) {
921 // This is probably too relaxed but it's existing behavior.
922 return;
923 }
924 if (get(inst)) {
925 // This is a public instance indeed.
926 return;
927 }
928 var received = void 0;
929 var stringified = '' + inst;
930 if (Array.isArray(inst)) {
931 received = 'an array';
932 } else if (inst && inst.nodeType === ELEMENT_NODE && inst.tagName) {
933 received = 'a DOM node';
934 } else if (stringified === '[object Object]') {
935 received = 'object with keys {' + Object.keys(inst).join(', ') + '}';
936 } else {
937 received = stringified;
938 }
939 invariant(false, '%s(...): the first argument must be a React class instance. Instead received: %s.', methodName, received);
940}
941
942/**
943 * Utilities for making it easy to test React components.
944 *
945 * See https://reactjs.org/docs/test-utils.html
946 *
947 * Todo: Support the entire DOM.scry query syntax. For now, these simple
948 * utilities will suffice for testing purposes.
949 * @lends ReactTestUtils
950 */
951var ReactTestUtils = {
952 renderIntoDocument: function (element) {
953 var div = document.createElement('div');
954 // None of our tests actually require attaching the container to the
955 // DOM, and doing so creates a mess that we rely on test isolation to
956 // clean up, so we're going to stop honoring the name of this method
957 // (and probably rename it eventually) if no problems arise.
958 // document.documentElement.appendChild(div);
959 return ReactDOM.render(element, div);
960 },
961
962 isElement: function (element) {
963 return React.isValidElement(element);
964 },
965
966 isElementOfType: function (inst, convenienceConstructor) {
967 return React.isValidElement(inst) && inst.type === convenienceConstructor;
968 },
969
970 isDOMComponent: function (inst) {
971 return !!(inst && inst.nodeType === ELEMENT_NODE && inst.tagName);
972 },
973
974 isDOMComponentElement: function (inst) {
975 return !!(inst && React.isValidElement(inst) && !!inst.tagName);
976 },
977
978 isCompositeComponent: function (inst) {
979 if (ReactTestUtils.isDOMComponent(inst)) {
980 // Accessing inst.setState warns; just return false as that'll be what
981 // this returns when we have DOM nodes as refs directly
982 return false;
983 }
984 return inst != null && typeof inst.render === 'function' && typeof inst.setState === 'function';
985 },
986
987 isCompositeComponentWithType: function (inst, type) {
988 if (!ReactTestUtils.isCompositeComponent(inst)) {
989 return false;
990 }
991 var internalInstance = get(inst);
992 var constructor = internalInstance.type;
993 return constructor === type;
994 },
995
996 findAllInRenderedTree: function (inst, test) {
997 validateClassInstance(inst, 'findAllInRenderedTree');
998 if (!inst) {
999 return [];
1000 }
1001 var internalInstance = get(inst);
1002 return findAllInRenderedFiberTreeInternal(internalInstance, test);
1003 },
1004
1005 /**
1006 * Finds all instance of components in the rendered tree that are DOM
1007 * components with the class name matching `className`.
1008 * @return {array} an array of all the matches.
1009 */
1010 scryRenderedDOMComponentsWithClass: function (root, classNames) {
1011 validateClassInstance(root, 'scryRenderedDOMComponentsWithClass');
1012 return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
1013 if (ReactTestUtils.isDOMComponent(inst)) {
1014 var className = inst.className;
1015 if (typeof className !== 'string') {
1016 // SVG, probably.
1017 className = inst.getAttribute('class') || '';
1018 }
1019 var classList = className.split(/\s+/);
1020
1021 if (!Array.isArray(classNames)) {
1022 !(classNames !== undefined) ? invariant(false, 'TestUtils.scryRenderedDOMComponentsWithClass expects a className as a second argument.') : void 0;
1023 classNames = classNames.split(/\s+/);
1024 }
1025 return classNames.every(function (name) {
1026 return classList.indexOf(name) !== -1;
1027 });
1028 }
1029 return false;
1030 });
1031 },
1032
1033 /**
1034 * Like scryRenderedDOMComponentsWithClass but expects there to be one result,
1035 * and returns that one result, or throws exception if there is any other
1036 * number of matches besides one.
1037 * @return {!ReactDOMComponent} The one match.
1038 */
1039 findRenderedDOMComponentWithClass: function (root, className) {
1040 validateClassInstance(root, 'findRenderedDOMComponentWithClass');
1041 var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
1042 if (all.length !== 1) {
1043 throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
1044 }
1045 return all[0];
1046 },
1047
1048 /**
1049 * Finds all instance of components in the rendered tree that are DOM
1050 * components with the tag name matching `tagName`.
1051 * @return {array} an array of all the matches.
1052 */
1053 scryRenderedDOMComponentsWithTag: function (root, tagName) {
1054 validateClassInstance(root, 'scryRenderedDOMComponentsWithTag');
1055 return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
1056 return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
1057 });
1058 },
1059
1060 /**
1061 * Like scryRenderedDOMComponentsWithTag but expects there to be one result,
1062 * and returns that one result, or throws exception if there is any other
1063 * number of matches besides one.
1064 * @return {!ReactDOMComponent} The one match.
1065 */
1066 findRenderedDOMComponentWithTag: function (root, tagName) {
1067 validateClassInstance(root, 'findRenderedDOMComponentWithTag');
1068 var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
1069 if (all.length !== 1) {
1070 throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
1071 }
1072 return all[0];
1073 },
1074
1075 /**
1076 * Finds all instances of components with type equal to `componentType`.
1077 * @return {array} an array of all the matches.
1078 */
1079 scryRenderedComponentsWithType: function (root, componentType) {
1080 validateClassInstance(root, 'scryRenderedComponentsWithType');
1081 return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
1082 return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
1083 });
1084 },
1085
1086 /**
1087 * Same as `scryRenderedComponentsWithType` but expects there to be one result
1088 * and returns that one result, or throws exception if there is any other
1089 * number of matches besides one.
1090 * @return {!ReactComponent} The one match.
1091 */
1092 findRenderedComponentWithType: function (root, componentType) {
1093 validateClassInstance(root, 'findRenderedComponentWithType');
1094 var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
1095 if (all.length !== 1) {
1096 throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
1097 }
1098 return all[0];
1099 },
1100
1101 /**
1102 * Pass a mocked component module to this method to augment it with
1103 * useful methods that allow it to be used as a dummy React component.
1104 * Instead of rendering as usual, the component will become a simple
1105 * <div> containing any provided children.
1106 *
1107 * @param {object} module the mock function object exported from a
1108 * module that defines the component to be mocked
1109 * @param {?string} mockTagName optional dummy root tag name to return
1110 * from render method (overrides
1111 * module.mockTagName if provided)
1112 * @return {object} the ReactTestUtils object (for chaining)
1113 */
1114 mockComponent: function (module, mockTagName) {
1115 if (!hasWarnedAboutDeprecatedMockComponent) {
1116 hasWarnedAboutDeprecatedMockComponent = true;
1117 lowPriorityWarning$1(false, 'ReactTestUtils.mockComponent() is deprecated. ' + 'Use shallow rendering or jest.mock() instead.\n\n' + 'See https://fb.me/test-utils-mock-component for more information.');
1118 }
1119
1120 mockTagName = mockTagName || module.mockTagName || 'div';
1121
1122 module.prototype.render.mockImplementation(function () {
1123 return React.createElement(mockTagName, null, this.props.children);
1124 });
1125
1126 return this;
1127 },
1128
1129 nativeTouchData: function (x, y) {
1130 return {
1131 touches: [{ pageX: x, pageY: y }]
1132 };
1133 },
1134
1135 Simulate: null,
1136 SimulateNative: {}
1137};
1138
1139/**
1140 * Exports:
1141 *
1142 * - `ReactTestUtils.Simulate.click(Element)`
1143 * - `ReactTestUtils.Simulate.mouseMove(Element)`
1144 * - `ReactTestUtils.Simulate.change(Element)`
1145 * - ... (All keys from event plugin `eventTypes` objects)
1146 */
1147function makeSimulator(eventType) {
1148 return function (domNode, eventData) {
1149 !!React.isValidElement(domNode) ? invariant(false, 'TestUtils.Simulate expected a DOM node as the first argument but received a React element. Pass the DOM node you wish to simulate the event on instead. Note that TestUtils.Simulate will not work if you are using shallow rendering.') : void 0;
1150 !!ReactTestUtils.isCompositeComponent(domNode) ? invariant(false, 'TestUtils.Simulate expected a DOM node as the first argument but received a component instance. Pass the DOM node you wish to simulate the event on instead.') : void 0;
1151
1152 var dispatchConfig = eventNameDispatchConfigs[eventType];
1153
1154 var fakeNativeEvent = new Event();
1155 fakeNativeEvent.target = domNode;
1156 fakeNativeEvent.type = eventType.toLowerCase();
1157
1158 // We don't use SyntheticEvent.getPooled in order to not have to worry about
1159 // properly destroying any properties assigned from `eventData` upon release
1160 var targetInst = getInstanceFromNode(domNode);
1161 var event = new SyntheticEvent(dispatchConfig, targetInst, fakeNativeEvent, domNode);
1162
1163 // Since we aren't using pooling, always persist the event. This will make
1164 // sure it's marked and won't warn when setting additional properties.
1165 event.persist();
1166 _assign(event, eventData);
1167
1168 if (dispatchConfig.phasedRegistrationNames) {
1169 accumulateTwoPhaseDispatches(event);
1170 } else {
1171 accumulateDirectDispatches(event);
1172 }
1173
1174 ReactDOM.unstable_batchedUpdates(function () {
1175 // Normally extractEvent enqueues a state restore, but we'll just always
1176 // do that since we we're by-passing it here.
1177 enqueueStateRestore(domNode);
1178 runEventsInBatch(event);
1179 });
1180 restoreStateIfNeeded();
1181 };
1182}
1183
1184function buildSimulators() {
1185 ReactTestUtils.Simulate = {};
1186
1187 var eventType = void 0;
1188 for (eventType in eventNameDispatchConfigs) {
1189 /**
1190 * @param {!Element|ReactDOMComponent} domComponentOrNode
1191 * @param {?object} eventData Fake event data to use in SyntheticEvent.
1192 */
1193 ReactTestUtils.Simulate[eventType] = makeSimulator(eventType);
1194 }
1195}
1196
1197buildSimulators();
1198
1199/**
1200 * Exports:
1201 *
1202 * - `ReactTestUtils.SimulateNative.click(Element/ReactDOMComponent)`
1203 * - `ReactTestUtils.SimulateNative.mouseMove(Element/ReactDOMComponent)`
1204 * - `ReactTestUtils.SimulateNative.mouseIn/ReactDOMComponent)`
1205 * - `ReactTestUtils.SimulateNative.mouseOut(Element/ReactDOMComponent)`
1206 * - ... (All keys from `BrowserEventConstants.topLevelTypes`)
1207 *
1208 * Note: Top level event types are a subset of the entire set of handler types
1209 * (which include a broader set of "synthetic" events). For example, onDragDone
1210 * is a synthetic event. Except when testing an event plugin or React's event
1211 * handling code specifically, you probably want to use ReactTestUtils.Simulate
1212 * to dispatch synthetic events.
1213 */
1214
1215function makeNativeSimulator(eventType, topLevelType) {
1216 return function (domComponentOrNode, nativeEventData) {
1217 var fakeNativeEvent = new Event(eventType);
1218 _assign(fakeNativeEvent, nativeEventData);
1219 if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
1220 simulateNativeEventOnDOMComponent(topLevelType, domComponentOrNode, fakeNativeEvent);
1221 } else if (domComponentOrNode.tagName) {
1222 // Will allow on actual dom nodes.
1223 simulateNativeEventOnNode(topLevelType, domComponentOrNode, fakeNativeEvent);
1224 }
1225 };
1226}
1227
1228[[TOP_ABORT, 'abort'], [TOP_ANIMATION_END, 'animationEnd'], [TOP_ANIMATION_ITERATION, 'animationIteration'], [TOP_ANIMATION_START, 'animationStart'], [TOP_BLUR, 'blur'], [TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], [TOP_CAN_PLAY, 'canPlay'], [TOP_CANCEL, 'cancel'], [TOP_CHANGE, 'change'], [TOP_CLICK, 'click'], [TOP_CLOSE, 'close'], [TOP_COMPOSITION_END, 'compositionEnd'], [TOP_COMPOSITION_START, 'compositionStart'], [TOP_COMPOSITION_UPDATE, 'compositionUpdate'], [TOP_CONTEXT_MENU, 'contextMenu'], [TOP_COPY, 'copy'], [TOP_CUT, 'cut'], [TOP_DOUBLE_CLICK, 'doubleClick'], [TOP_DRAG_END, 'dragEnd'], [TOP_DRAG_ENTER, 'dragEnter'], [TOP_DRAG_EXIT, 'dragExit'], [TOP_DRAG_LEAVE, 'dragLeave'], [TOP_DRAG_OVER, 'dragOver'], [TOP_DRAG_START, 'dragStart'], [TOP_DRAG, 'drag'], [TOP_DROP, 'drop'], [TOP_DURATION_CHANGE, 'durationChange'], [TOP_EMPTIED, 'emptied'], [TOP_ENCRYPTED, 'encrypted'], [TOP_ENDED, 'ended'], [TOP_ERROR, 'error'], [TOP_FOCUS, 'focus'], [TOP_INPUT, 'input'], [TOP_KEY_DOWN, 'keyDown'], [TOP_KEY_PRESS, 'keyPress'], [TOP_KEY_UP, 'keyUp'], [TOP_LOAD_START, 'loadStart'], [TOP_LOAD_START, 'loadStart'], [TOP_LOAD, 'load'], [TOP_LOADED_DATA, 'loadedData'], [TOP_LOADED_METADATA, 'loadedMetadata'], [TOP_MOUSE_DOWN, 'mouseDown'], [TOP_MOUSE_MOVE, 'mouseMove'], [TOP_MOUSE_OUT, 'mouseOut'], [TOP_MOUSE_OVER, 'mouseOver'], [TOP_MOUSE_UP, 'mouseUp'], [TOP_PASTE, 'paste'], [TOP_PAUSE, 'pause'], [TOP_PLAY, 'play'], [TOP_PLAYING, 'playing'], [TOP_PROGRESS, 'progress'], [TOP_RATE_CHANGE, 'rateChange'], [TOP_SCROLL, 'scroll'], [TOP_SEEKED, 'seeked'], [TOP_SEEKING, 'seeking'], [TOP_SELECTION_CHANGE, 'selectionChange'], [TOP_STALLED, 'stalled'], [TOP_SUSPEND, 'suspend'], [TOP_TEXT_INPUT, 'textInput'], [TOP_TIME_UPDATE, 'timeUpdate'], [TOP_TOGGLE, 'toggle'], [TOP_TOUCH_CANCEL, 'touchCancel'], [TOP_TOUCH_END, 'touchEnd'], [TOP_TOUCH_MOVE, 'touchMove'], [TOP_TOUCH_START, 'touchStart'], [TOP_TRANSITION_END, 'transitionEnd'], [TOP_VOLUME_CHANGE, 'volumeChange'], [TOP_WAITING, 'waiting'], [TOP_WHEEL, 'wheel']].forEach(function (_ref) {
1229 var topLevelType = _ref[0],
1230 eventType = _ref[1];
1231
1232 /**
1233 * @param {!Element|ReactDOMComponent} domComponentOrNode
1234 * @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
1235 */
1236 ReactTestUtils.SimulateNative[eventType] = makeNativeSimulator(eventType, topLevelType);
1237});
1238
1239
1240
1241var ReactTestUtils$2 = Object.freeze({
1242 default: ReactTestUtils
1243});
1244
1245var ReactTestUtils$3 = ( ReactTestUtils$2 && ReactTestUtils ) || ReactTestUtils$2;
1246
1247// TODO: decide on the top-level export form.
1248// This is hacky but makes it work with both Rollup and Jest.
1249var testUtils = ReactTestUtils$3.default || ReactTestUtils$3;
1250
1251return testUtils;
1252
1253})));