react-palm
Version:
Elm-like architecture for React apps
467 lines (414 loc) • 15.2 kB
JavaScript
/** @license React v16.8.4+patch
* react-dom-test-utils.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
(function (g, m) {
"object" === (typeof exports === "undefined" ? "undefined" : _typeof(exports)) && "undefined" !== typeof module ? module.exports = m(require("react"), require("react-dom")) : "function" === typeof define && define.amd ? define(["react", "react-dom"], m) : g.ReactTestUtils = m(g.React, g.ReactDOM);
})(void 0, function (g, m) {
function H(a, b, c, e, d, f, h, J) {
if (!a) {
a = void 0;
if (void 0 === b) a = Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else {
var g = [c, e, d, f, h, J],
I = 0;
a = Error(b.replace(/%s/g, function () {
return g[I++];
}));
a.name = "Invariant Violation";
}
a.framesToPop = 1;
throw a;
}
}
function l(a) {
for (var b = arguments.length - 1, c = "https://reactjs.org/docs/error-decoder.html?invariant=" + a, e = 0; e < b; e++) {
c += "&args[]=" + encodeURIComponent(arguments[e + 1]);
}
H(!1, "Minified React error #" + a + "; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ", c);
}
function A(a) {
var b = a;
if (a.alternate) for (; b.return;) {
b = b.return;
} else {
if (0 !== (b.effectTag & 2)) return 1;
for (; b.return;) {
if (b = b.return, 0 !== (b.effectTag & 2)) return 1;
}
}
return 3 === b.tag ? 2 : 3;
}
function B(a) {
2 !== A(a) ? l("188") : void 0;
}
function K(a) {
var b = a.alternate;
if (!b) return b = A(a), 3 === b ? l("188") : void 0, 1 === b ? null : a;
for (var c = a, e = b;;) {
var d = c.return,
f = d ? d.alternate : null;
if (!d || !f) break;
if (d.child === f.child) {
for (var h = d.child; h;) {
if (h === c) return B(d), a;
if (h === e) return B(d), b;
h = h.sibling;
}
l("188");
}
if (c.return !== e.return) c = d, e = f;else {
h = !1;
for (var g = d.child; g;) {
if (g === c) {
h = !0;
c = d;
e = f;
break;
}
if (g === e) {
h = !0;
e = d;
c = f;
break;
}
g = g.sibling;
}
if (!h) {
for (g = f.child; g;) {
if (g === c) {
h = !0;
c = f;
e = d;
break;
}
if (g === e) {
h = !0;
e = f;
c = d;
break;
}
g = g.sibling;
}
h ? void 0 : l("189");
}
}
c.alternate !== e ? l("190") : void 0;
}
3 !== c.tag ? l("188") : void 0;
return c.stateNode.current === c ? a : b;
}
function u() {
return !0;
}
function v() {
return !1;
}
function r(a, b, c, e) {
this.dispatchConfig = a;
this._targetInst = b;
this.nativeEvent = c;
a = this.constructor.Interface;
for (var d in a) {
a.hasOwnProperty(d) && ((b = a[d]) ? this[d] = b(c) : "target" === d ? this.target = e : this[d] = c[d]);
}
this.isDefaultPrevented = (null != c.defaultPrevented ? c.defaultPrevented : !1 === c.returnValue) ? u : v;
this.isPropagationStopped = v;
return this;
}
function L(a, b, c, e) {
if (this.eventPool.length) {
var d = this.eventPool.pop();
this.call(d, a, b, c, e);
return d;
}
return new this(a, b, c, e);
}
function M(a) {
a instanceof this ? void 0 : l("279");
a.destructor();
10 > this.eventPool.length && this.eventPool.push(a);
}
function C(a) {
a.eventPool = [];
a.getPooled = L;
a.release = M;
}
function w(a, b) {
var c = {};
c[a.toLowerCase()] = b.toLowerCase();
c["Webkit" + a] = "webkit" + b;
c["Moz" + a] = "moz" + b;
return c;
}
function x(a) {
if (y[a]) return y[a];
if (!q[a]) return a;
var b = q[a],
c;
for (c in b) {
if (b.hasOwnProperty(c) && c in D) return y[a] = b[c];
}
return a;
}
function E(a) {}
function N(a, b) {
if (!a) return [];
a = K(a);
if (!a) return [];
for (var c = a, e = [];;) {
if (5 === c.tag || 6 === c.tag || 1 === c.tag || 0 === c.tag) {
var d = c.stateNode;
b(d) && e.push(d);
}
if (c.child) c.child.return = c, c = c.child;else {
if (c === a) return e;
for (; !c.sibling;) {
if (!c.return || c.return === a) return e;
c = c.return;
}
c.sibling.return = c.return;
c = c.sibling;
}
}
}
function p(a, b) {
if (a && !a._reactInternalFiber) {
var c = "" + a;
a = Array.isArray(a) ? "an array" : a && 1 === a.nodeType && a.tagName ? "a DOM node" : "[object Object]" === c ? "object with keys {" + Object.keys(a).join(", ") + "}" : c;
l("286", b, a);
}
}
function O(a) {
return function (b, c) {
g.isValidElement(b) ? l("228") : void 0;
f.isCompositeComponent(b) ? l("229") : void 0;
var e = F[a],
d = new E();
d.target = b;
d.type = a.toLowerCase();
var k = P(b),
h = new r(e, k, d, b);
h.persist();
t(h, c);
e.phasedRegistrationNames ? Q(h) : R(h);
m.unstable_batchedUpdates(function () {
S(b);
T(h);
});
U();
};
}
function V(a, b) {
return function (c, e) {
var d = new E(a);
t(d, e);
f.isDOMComponent(c) ? (c = W(c), d.target = c, G(b, d)) : c.tagName && (d.target = c, G(b, d));
};
}
var t = g.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.assign,
k = g.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
k.hasOwnProperty("ReactCurrentDispatcher") || (k.ReactCurrentDispatcher = {
current: null
});
t(r.prototype, {
preventDefault: function preventDefault() {
this.defaultPrevented = !0;
var a = this.nativeEvent;
a && (a.preventDefault ? a.preventDefault() : "unknown" !== typeof a.returnValue && (a.returnValue = !1), this.isDefaultPrevented = u);
},
stopPropagation: function stopPropagation() {
var a = this.nativeEvent;
a && (a.stopPropagation ? a.stopPropagation() : "unknown" !== typeof a.cancelBubble && (a.cancelBubble = !0), this.isPropagationStopped = u);
},
persist: function persist() {
this.isPersistent = u;
},
isPersistent: v,
destructor: function destructor() {
var a = this.constructor.Interface,
b;
for (b in a) {
this[b] = null;
}
this.nativeEvent = this._targetInst = this.dispatchConfig = null;
this.isPropagationStopped = this.isDefaultPrevented = v;
this._dispatchInstances = this._dispatchListeners = null;
}
});
r.Interface = {
type: null,
target: null,
currentTarget: function currentTarget() {
return null;
},
eventPhase: null,
bubbles: null,
cancelable: null,
timeStamp: function timeStamp(a) {
return a.timeStamp || Date.now();
},
defaultPrevented: null,
isTrusted: null
};
r.extend = function (a) {
function b() {
return c.apply(this, arguments);
}
var c = this,
e = function e() {};
e.prototype = c.prototype;
e = new e();
t(e, b.prototype);
b.prototype = e;
b.prototype.constructor = b;
b.Interface = t({}, c.Interface, a);
b.extend = c.extend;
C(b);
return b;
};
C(r);
k = !("undefined" === typeof window || !window.document || !window.document.createElement);
var q = {
animationend: w("Animation", "AnimationEnd"),
animationiteration: w("Animation", "AnimationIteration"),
animationstart: w("Animation", "AnimationStart"),
transitionend: w("Transition", "TransitionEnd")
},
y = {},
D = {};
k && (D = document.createElement("div").style, "AnimationEvent" in window || (delete q.animationend.animation, delete q.animationiteration.animation, delete q.animationstart.animation), "TransitionEvent" in window || delete q.transitionend.transition);
k = x("animationend");
var X = x("animationiteration"),
Y = x("animationstart"),
Z = x("transitionend"),
W = m.findDOMNode,
n = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events,
P = n[0],
F = n[4],
Q = n[5],
R = n[6],
S = n[7],
U = n[8],
G = n[9],
T = n[10],
z = null,
f = {
renderIntoDocument: function renderIntoDocument(a) {
var b = document.createElement("div");
return m.render(a, b);
},
isElement: function isElement(a) {
return g.isValidElement(a);
},
isElementOfType: function isElementOfType(a, b) {
return g.isValidElement(a) && a.type === b;
},
isDOMComponent: function isDOMComponent(a) {
return !(!a || 1 !== a.nodeType || !a.tagName);
},
isDOMComponentElement: function isDOMComponentElement(a) {
return !!(a && g.isValidElement(a) && a.tagName);
},
isCompositeComponent: function isCompositeComponent(a) {
return f.isDOMComponent(a) ? !1 : null != a && "function" === typeof a.render && "function" === typeof a.setState;
},
isCompositeComponentWithType: function isCompositeComponentWithType(a, b) {
return f.isCompositeComponent(a) ? a._reactInternalFiber.type === b : !1;
},
findAllInRenderedTree: function findAllInRenderedTree(a, b) {
p(a, "findAllInRenderedTree");
return a ? N(a._reactInternalFiber, b) : [];
},
scryRenderedDOMComponentsWithClass: function scryRenderedDOMComponentsWithClass(a, b) {
p(a, "scryRenderedDOMComponentsWithClass");
return f.findAllInRenderedTree(a, function (a) {
if (f.isDOMComponent(a)) {
var c = a.className;
"string" !== typeof c && (c = a.getAttribute("class") || "");
var d = c.split(/\s+/);
Array.isArray(b) || (void 0 === b ? l("11") : void 0, b = b.split(/\s+/));
return b.every(function (a) {
return -1 !== d.indexOf(a);
});
}
return !1;
});
},
findRenderedDOMComponentWithClass: function findRenderedDOMComponentWithClass(a, b) {
p(a, "findRenderedDOMComponentWithClass");
a = f.scryRenderedDOMComponentsWithClass(a, b);
if (1 !== a.length) throw Error("Did not find exactly one match (found: " + a.length + ") for class:" + b);
return a[0];
},
scryRenderedDOMComponentsWithTag: function scryRenderedDOMComponentsWithTag(a, b) {
p(a, "scryRenderedDOMComponentsWithTag");
return f.findAllInRenderedTree(a, function (a) {
return f.isDOMComponent(a) && a.tagName.toUpperCase() === b.toUpperCase();
});
},
findRenderedDOMComponentWithTag: function findRenderedDOMComponentWithTag(a, b) {
p(a, "findRenderedDOMComponentWithTag");
a = f.scryRenderedDOMComponentsWithTag(a, b);
if (1 !== a.length) throw Error("Did not find exactly one match (found: " + a.length + ") for tag:" + b);
return a[0];
},
scryRenderedComponentsWithType: function scryRenderedComponentsWithType(a, b) {
p(a, "scryRenderedComponentsWithType");
return f.findAllInRenderedTree(a, function (a) {
return f.isCompositeComponentWithType(a, b);
});
},
findRenderedComponentWithType: function findRenderedComponentWithType(a, b) {
p(a, "findRenderedComponentWithType");
a = f.scryRenderedComponentsWithType(a, b);
if (1 !== a.length) throw Error("Did not find exactly one match (found: " + a.length + ") for componentType:" + b);
return a[0];
},
mockComponent: function mockComponent(a, b) {
b = b || a.mockTagName || "div";
a.prototype.render.mockImplementation(function () {
return g.createElement(b, null, this.props.children);
});
return this;
},
nativeTouchData: function nativeTouchData(a, b) {
return {
touches: [{
pageX: a,
pageY: b
}]
};
},
Simulate: null,
SimulateNative: {},
act: function act(a) {
null === z && (z = document.createElement("div"));
m.unstable_batchedUpdates(a);
m.render(g.createElement("div", null), z);
return {
then: function then() {}
};
}
};
(function () {
f.Simulate = {};
var a = void 0;
for (a in F) {
f.Simulate[a] = O(a);
}
})();
[["abort", "abort"], [k, "animationEnd"], [X, "animationIteration"], [Y, "animationStart"], ["blur", "blur"], ["canplaythrough", "canPlayThrough"], ["canplay", "canPlay"], ["cancel", "cancel"], ["change", "change"], ["click", "click"], ["close", "close"], ["compositionend", "compositionEnd"], ["compositionstart", "compositionStart"], ["compositionupdate", "compositionUpdate"], ["contextmenu", "contextMenu"], ["copy", "copy"], ["cut", "cut"], ["dblclick", "doubleClick"], ["dragend", "dragEnd"], ["dragenter", "dragEnter"], ["dragexit", "dragExit"], ["dragleave", "dragLeave"], ["dragover", "dragOver"], ["dragstart", "dragStart"], ["drag", "drag"], ["drop", "drop"], ["durationchange", "durationChange"], ["emptied", "emptied"], ["encrypted", "encrypted"], ["ended", "ended"], ["error", "error"], ["focus", "focus"], ["input", "input"], ["keydown", "keyDown"], ["keypress", "keyPress"], ["keyup", "keyUp"], ["loadstart", "loadStart"], ["loadstart", "loadStart"], ["load", "load"], ["loadeddata", "loadedData"], ["loadedmetadata", "loadedMetadata"], ["mousedown", "mouseDown"], ["mousemove", "mouseMove"], ["mouseout", "mouseOut"], ["mouseover", "mouseOver"], ["mouseup", "mouseUp"], ["paste", "paste"], ["pause", "pause"], ["play", "play"], ["playing", "playing"], ["progress", "progress"], ["ratechange", "rateChange"], ["scroll", "scroll"], ["seeked", "seeked"], ["seeking", "seeking"], ["selectionchange", "selectionChange"], ["stalled", "stalled"], ["suspend", "suspend"], ["textInput", "textInput"], ["timeupdate", "timeUpdate"], ["toggle", "toggle"], ["touchcancel", "touchCancel"], ["touchend", "touchEnd"], ["touchmove", "touchMove"], ["touchstart", "touchStart"], [Z, "transitionEnd"], ["volumechange", "volumeChange"], ["waiting", "waiting"], ["wheel", "wheel"]].forEach(function (a) {
var b = a[1];
f.SimulateNative[b] = V(b, a[0]);
});
k = (k = {
default: f
}, f) || k;
return k.default || k;
});