react-test-renderer 16.4.2 → 16.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/react-test-renderer-shallow.development.js +212 -24
- package/cjs/react-test-renderer-shallow.production.min.js +18 -17
- package/cjs/react-test-renderer.development.js +2929 -1809
- package/cjs/react-test-renderer.production.min.js +123 -112
- package/package.json +4 -4
- package/umd/react-test-renderer-shallow.development.js +160 -173
- package/umd/react-test-renderer-shallow.production.min.js +13 -13
- package/umd/react-test-renderer.development.js +2896 -1964
- package/umd/react-test-renderer.production.min.js +103 -93
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-test-renderer",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.5.0",
|
|
4
4
|
"description": "React package for snapshot testing.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "facebook/react",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
},
|
|
16
16
|
"homepage": "https://reactjs.org/",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"fbjs": "^0.8.16",
|
|
19
18
|
"object-assign": "^4.1.1",
|
|
20
|
-
"prop-types": "^15.6.
|
|
21
|
-
"react-is": "^16.
|
|
19
|
+
"prop-types": "^15.6.2",
|
|
20
|
+
"react-is": "^16.5.0",
|
|
21
|
+
"schedule": "^0.3.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "^16.0.0"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.5.0
|
|
2
2
|
* react-test-renderer-shallow.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -19,16 +19,6 @@ var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
|
19
19
|
|
|
20
20
|
var _assign = ReactInternals.assign;
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
24
|
-
*
|
|
25
|
-
* This source code is licensed under the MIT license found in the
|
|
26
|
-
* LICENSE file in the root directory of this source tree.
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
22
|
/**
|
|
33
23
|
* Use invariant() to assert state which your program assumes to be true.
|
|
34
24
|
*
|
|
@@ -40,10 +30,10 @@ var _assign = ReactInternals.assign;
|
|
|
40
30
|
* will remain to ensure logic does not differ in production.
|
|
41
31
|
*/
|
|
42
32
|
|
|
43
|
-
var validateFormat = function
|
|
33
|
+
var validateFormat = function () {};
|
|
44
34
|
|
|
45
35
|
{
|
|
46
|
-
validateFormat = function
|
|
36
|
+
validateFormat = function (format) {
|
|
47
37
|
if (format === undefined) {
|
|
48
38
|
throw new Error('invariant requires an error message argument');
|
|
49
39
|
}
|
|
@@ -54,7 +44,7 @@ function invariant(condition, format, a, b, c, d, e, f) {
|
|
|
54
44
|
validateFormat(format);
|
|
55
45
|
|
|
56
46
|
if (!condition) {
|
|
57
|
-
var error;
|
|
47
|
+
var error = void 0;
|
|
58
48
|
if (format === undefined) {
|
|
59
49
|
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
60
50
|
} else {
|
|
@@ -71,10 +61,8 @@ function invariant(condition, format, a, b, c, d, e, f) {
|
|
|
71
61
|
}
|
|
72
62
|
}
|
|
73
63
|
|
|
74
|
-
var invariant_1 = invariant;
|
|
75
|
-
|
|
76
64
|
// Relying on the `invariant()` implementation lets us
|
|
77
|
-
//
|
|
65
|
+
// preserve the format and params in the www builds.
|
|
78
66
|
|
|
79
67
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
80
68
|
// nor polyfill, then a plain number is used for performance.
|
|
@@ -89,7 +77,7 @@ var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
|
89
77
|
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
|
90
78
|
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
91
79
|
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
92
|
-
var
|
|
80
|
+
var REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for('react.placeholder') : 0xead1;
|
|
93
81
|
|
|
94
82
|
function typeOf(object) {
|
|
95
83
|
if (typeof object === 'object' && object !== null) {
|
|
@@ -143,15 +131,99 @@ function isForwardRef(object) {
|
|
|
143
131
|
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
144
132
|
}
|
|
145
133
|
|
|
134
|
+
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
|
135
|
+
|
|
146
136
|
var describeComponentFrame = function (name, source, ownerName) {
|
|
147
|
-
|
|
137
|
+
var sourceInfo = '';
|
|
138
|
+
if (source) {
|
|
139
|
+
var path = source.fileName;
|
|
140
|
+
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
|
141
|
+
{
|
|
142
|
+
// In DEV, include code for a common special case:
|
|
143
|
+
// prefer "folder/index.js" instead of just "index.js".
|
|
144
|
+
if (/^index\./.test(fileName)) {
|
|
145
|
+
var match = path.match(BEFORE_SLASH_RE);
|
|
146
|
+
if (match) {
|
|
147
|
+
var pathBeforeSlash = match[1];
|
|
148
|
+
if (pathBeforeSlash) {
|
|
149
|
+
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
|
150
|
+
fileName = folderName + '/' + fileName;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
|
156
|
+
} else if (ownerName) {
|
|
157
|
+
sourceInfo = ' (created by ' + ownerName + ')';
|
|
158
|
+
}
|
|
159
|
+
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
|
148
160
|
};
|
|
149
161
|
|
|
150
|
-
|
|
151
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
|
164
|
+
* This can be used to log issues in development environments in critical
|
|
165
|
+
* paths. Removing the logging code for production environments will keep the
|
|
166
|
+
* same logic and follow the same code paths.
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
var warningWithoutStack = function () {};
|
|
170
|
+
|
|
171
|
+
{
|
|
172
|
+
warningWithoutStack = function (condition, format) {
|
|
173
|
+
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
174
|
+
args[_key - 2] = arguments[_key];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (format === undefined) {
|
|
178
|
+
throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
179
|
+
}
|
|
180
|
+
if (condition) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (typeof console !== 'undefined') {
|
|
184
|
+
var _console;
|
|
152
185
|
|
|
186
|
+
var stringArgs = args.map(function (item) {
|
|
187
|
+
return '' + item;
|
|
188
|
+
});
|
|
189
|
+
(_console = console).error.apply(_console, ['Warning: ' + format].concat(stringArgs));
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
192
|
+
// --- Welcome to debugging React ---
|
|
193
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
194
|
+
// to find the callsite that caused this warning to fire.
|
|
195
|
+
var argIndex = 0;
|
|
196
|
+
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
|
197
|
+
return args[argIndex++];
|
|
198
|
+
});
|
|
199
|
+
throw new Error(message);
|
|
200
|
+
} catch (x) {}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
var warningWithoutStack$1 = warningWithoutStack;
|
|
205
|
+
|
|
206
|
+
var Resolved = 1;
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
function refineResolvedThenable(thenable) {
|
|
212
|
+
return thenable._reactStatus === Resolved ? thenable._reactResult : null;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function getComponentName(type) {
|
|
216
|
+
if (type == null) {
|
|
217
|
+
// Host root, text node or just invalid type.
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
{
|
|
221
|
+
if (typeof type.tag === 'number') {
|
|
222
|
+
warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
153
225
|
if (typeof type === 'function') {
|
|
154
|
-
return type.displayName || type.name;
|
|
226
|
+
return type.displayName || type.name || null;
|
|
155
227
|
}
|
|
156
228
|
if (typeof type === 'string') {
|
|
157
229
|
return type;
|
|
@@ -159,63 +231,41 @@ function getComponentName(fiber) {
|
|
|
159
231
|
switch (type) {
|
|
160
232
|
case REACT_ASYNC_MODE_TYPE:
|
|
161
233
|
return 'AsyncMode';
|
|
162
|
-
case REACT_CONTEXT_TYPE:
|
|
163
|
-
return 'Context.Consumer';
|
|
164
234
|
case REACT_FRAGMENT_TYPE:
|
|
165
|
-
return '
|
|
235
|
+
return 'Fragment';
|
|
166
236
|
case REACT_PORTAL_TYPE:
|
|
167
|
-
return '
|
|
237
|
+
return 'Portal';
|
|
168
238
|
case REACT_PROFILER_TYPE:
|
|
169
|
-
return 'Profiler
|
|
170
|
-
case REACT_PROVIDER_TYPE:
|
|
171
|
-
return 'Context.Provider';
|
|
239
|
+
return 'Profiler';
|
|
172
240
|
case REACT_STRICT_MODE_TYPE:
|
|
173
241
|
return 'StrictMode';
|
|
174
|
-
case
|
|
175
|
-
return '
|
|
242
|
+
case REACT_PLACEHOLDER_TYPE:
|
|
243
|
+
return 'Placeholder';
|
|
176
244
|
}
|
|
177
|
-
if (typeof type === 'object'
|
|
245
|
+
if (typeof type === 'object') {
|
|
178
246
|
switch (type.$$typeof) {
|
|
247
|
+
case REACT_CONTEXT_TYPE:
|
|
248
|
+
return 'Context.Consumer';
|
|
249
|
+
case REACT_PROVIDER_TYPE:
|
|
250
|
+
return 'Context.Provider';
|
|
179
251
|
case REACT_FORWARD_REF_TYPE:
|
|
180
|
-
var
|
|
252
|
+
var renderFn = type.render;
|
|
253
|
+
var functionName = renderFn.displayName || renderFn.name || '';
|
|
181
254
|
return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
|
|
182
255
|
}
|
|
256
|
+
if (typeof type.then === 'function') {
|
|
257
|
+
var thenable = type;
|
|
258
|
+
var resolvedThenable = refineResolvedThenable(thenable);
|
|
259
|
+
if (resolvedThenable) {
|
|
260
|
+
return getComponentName(resolvedThenable);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
183
263
|
}
|
|
184
264
|
return null;
|
|
185
265
|
}
|
|
186
266
|
|
|
187
|
-
/**
|
|
188
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
189
|
-
*
|
|
190
|
-
* This source code is licensed under the MIT license found in the
|
|
191
|
-
* LICENSE file in the root directory of this source tree.
|
|
192
|
-
*
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
var emptyObject = {};
|
|
198
|
-
|
|
199
|
-
{
|
|
200
|
-
Object.freeze(emptyObject);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
var emptyObject_1 = emptyObject;
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
207
|
-
*
|
|
208
|
-
* This source code is licensed under the MIT license found in the
|
|
209
|
-
* LICENSE file in the root directory of this source tree.
|
|
210
|
-
*
|
|
211
|
-
* @typechecks
|
|
212
|
-
*
|
|
213
|
-
*/
|
|
214
|
-
|
|
215
267
|
/*eslint-disable no-self-compare */
|
|
216
268
|
|
|
217
|
-
|
|
218
|
-
|
|
219
269
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
220
270
|
|
|
221
271
|
/**
|
|
@@ -266,74 +316,36 @@ function shallowEqual(objA, objB) {
|
|
|
266
316
|
return true;
|
|
267
317
|
}
|
|
268
318
|
|
|
269
|
-
var shallowEqual_1 = shallowEqual;
|
|
270
|
-
|
|
271
319
|
/**
|
|
272
320
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
273
321
|
*
|
|
274
322
|
* This source code is licensed under the MIT license found in the
|
|
275
323
|
* LICENSE file in the root directory of this source tree.
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
324
|
*/
|
|
279
325
|
|
|
280
|
-
function makeEmptyFunction(arg) {
|
|
281
|
-
return function () {
|
|
282
|
-
return arg;
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
326
|
|
|
286
|
-
/**
|
|
287
|
-
* This function accepts and discards inputs; it has no side effects. This is
|
|
288
|
-
* primarily useful idiomatically for overridable function endpoints which
|
|
289
|
-
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
|
|
290
|
-
*/
|
|
291
|
-
var emptyFunction = function emptyFunction() {};
|
|
292
|
-
|
|
293
|
-
emptyFunction.thatReturns = makeEmptyFunction;
|
|
294
|
-
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
|
295
|
-
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
|
296
|
-
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
|
297
|
-
emptyFunction.thatReturnsThis = function () {
|
|
298
|
-
return this;
|
|
299
|
-
};
|
|
300
|
-
emptyFunction.thatReturnsArgument = function (arg) {
|
|
301
|
-
return arg;
|
|
302
|
-
};
|
|
303
327
|
|
|
304
|
-
var
|
|
328
|
+
var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
329
|
+
|
|
330
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
|
305
331
|
|
|
306
332
|
/**
|
|
307
|
-
* Copyright (c)
|
|
333
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
308
334
|
*
|
|
309
335
|
* This source code is licensed under the MIT license found in the
|
|
310
336
|
* LICENSE file in the root directory of this source tree.
|
|
311
|
-
*
|
|
312
337
|
*/
|
|
313
338
|
|
|
314
339
|
|
|
315
340
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Similar to invariant but only logs a warning if the condition is not met.
|
|
320
|
-
* This can be used to log issues in development environments in critical
|
|
321
|
-
* paths. Removing the logging code for production environments will keep the
|
|
322
|
-
* same logic and follow the same code paths.
|
|
323
|
-
*/
|
|
324
|
-
|
|
325
|
-
var warning$1 = emptyFunction_1;
|
|
341
|
+
var printWarning = function() {};
|
|
326
342
|
|
|
327
343
|
{
|
|
328
|
-
var
|
|
329
|
-
|
|
330
|
-
args[_key - 1] = arguments[_key];
|
|
331
|
-
}
|
|
344
|
+
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
345
|
+
var loggedTypeFailures = {};
|
|
332
346
|
|
|
333
|
-
|
|
334
|
-
var message = 'Warning: ' +
|
|
335
|
-
return args[argIndex++];
|
|
336
|
-
});
|
|
347
|
+
printWarning = function(text) {
|
|
348
|
+
var message = 'Warning: ' + text;
|
|
337
349
|
if (typeof console !== 'undefined') {
|
|
338
350
|
console.error(message);
|
|
339
351
|
}
|
|
@@ -344,55 +356,6 @@ var warning$1 = emptyFunction_1;
|
|
|
344
356
|
throw new Error(message);
|
|
345
357
|
} catch (x) {}
|
|
346
358
|
};
|
|
347
|
-
|
|
348
|
-
warning$1 = function warning(condition, format) {
|
|
349
|
-
if (format === undefined) {
|
|
350
|
-
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
if (format.indexOf('Failed Composite propType: ') === 0) {
|
|
354
|
-
return; // Ignore CompositeComponent proptype check.
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
if (!condition) {
|
|
358
|
-
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
359
|
-
args[_key2 - 2] = arguments[_key2];
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
printWarning.apply(undefined, [format].concat(args));
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
var warning_1 = warning$1;
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
371
|
-
*
|
|
372
|
-
* This source code is licensed under the MIT license found in the
|
|
373
|
-
* LICENSE file in the root directory of this source tree.
|
|
374
|
-
*/
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
379
|
-
|
|
380
|
-
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
384
|
-
*
|
|
385
|
-
* This source code is licensed under the MIT license found in the
|
|
386
|
-
* LICENSE file in the root directory of this source tree.
|
|
387
|
-
*/
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
{
|
|
392
|
-
var invariant$2 = invariant_1;
|
|
393
|
-
var warning = warning_1;
|
|
394
|
-
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
395
|
-
var loggedTypeFailures = {};
|
|
396
359
|
}
|
|
397
360
|
|
|
398
361
|
/**
|
|
@@ -417,12 +380,29 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
|
417
380
|
try {
|
|
418
381
|
// This is intentionally an invariant that gets caught. It's the same
|
|
419
382
|
// behavior as without this statement except with a better message.
|
|
420
|
-
|
|
383
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
384
|
+
var err = Error(
|
|
385
|
+
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
|
386
|
+
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
|
387
|
+
);
|
|
388
|
+
err.name = 'Invariant Violation';
|
|
389
|
+
throw err;
|
|
390
|
+
}
|
|
421
391
|
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
422
392
|
} catch (ex) {
|
|
423
393
|
error = ex;
|
|
424
394
|
}
|
|
425
|
-
|
|
395
|
+
if (error && !(error instanceof Error)) {
|
|
396
|
+
printWarning(
|
|
397
|
+
(componentName || 'React class') + ': type specification of ' +
|
|
398
|
+
location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
|
399
|
+
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
|
400
|
+
'You may have forgotten to pass an argument to the type checker ' +
|
|
401
|
+
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
|
402
|
+
'shape all require an argument).'
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
}
|
|
426
406
|
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
427
407
|
// Only monitor this failure once because there tends to be a lot of the
|
|
428
408
|
// same error.
|
|
@@ -430,7 +410,9 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
|
430
410
|
|
|
431
411
|
var stack = getStack ? getStack() : '';
|
|
432
412
|
|
|
433
|
-
|
|
413
|
+
printWarning(
|
|
414
|
+
'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
|
415
|
+
);
|
|
434
416
|
}
|
|
435
417
|
}
|
|
436
418
|
}
|
|
@@ -441,6 +423,11 @@ var checkPropTypes_1 = checkPropTypes;
|
|
|
441
423
|
|
|
442
424
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
443
425
|
|
|
426
|
+
var emptyObject = {};
|
|
427
|
+
{
|
|
428
|
+
Object.freeze(emptyObject);
|
|
429
|
+
}
|
|
430
|
+
|
|
444
431
|
var ReactShallowRenderer = function () {
|
|
445
432
|
function ReactShallowRenderer() {
|
|
446
433
|
_classCallCheck(this, ReactShallowRenderer);
|
|
@@ -464,12 +451,12 @@ var ReactShallowRenderer = function () {
|
|
|
464
451
|
};
|
|
465
452
|
|
|
466
453
|
ReactShallowRenderer.prototype.render = function render(element) {
|
|
467
|
-
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
454
|
+
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : emptyObject;
|
|
468
455
|
|
|
469
|
-
!React.isValidElement(element) ?
|
|
456
|
+
!React.isValidElement(element) ? invariant(false, 'ReactShallowRenderer render(): Invalid component element.%s', typeof element === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' : '') : void 0;
|
|
470
457
|
// Show a special message for host elements since it's a common case.
|
|
471
|
-
!(typeof element.type !== 'string') ?
|
|
472
|
-
!(isForwardRef(element) || typeof element.type === 'function') ?
|
|
458
|
+
!(typeof element.type !== 'string') ? invariant(false, 'ReactShallowRenderer render(): Shallow rendering works only with custom components, not primitives (%s). Instead of calling `.render(el)` and inspecting the rendered output, look at `el.props` directly instead.', element.type) : void 0;
|
|
459
|
+
!(isForwardRef(element) || typeof element.type === 'function') ? invariant(false, 'ReactShallowRenderer render(): Shallow rendering works only with custom components, but the provided element type was `%s`.', Array.isArray(element.type) ? 'array' : element.type === null ? 'null' : typeof element.type) : void 0;
|
|
473
460
|
|
|
474
461
|
if (this._rendering) {
|
|
475
462
|
return;
|
|
@@ -499,7 +486,7 @@ var ReactShallowRenderer = function () {
|
|
|
499
486
|
|
|
500
487
|
this._mountClassComponent(element, this._context);
|
|
501
488
|
} else {
|
|
502
|
-
this._rendered = element.type(element.props, this._context);
|
|
489
|
+
this._rendered = element.type.call(undefined, element.props, this._context);
|
|
503
490
|
}
|
|
504
491
|
}
|
|
505
492
|
|
|
@@ -545,7 +532,7 @@ var ReactShallowRenderer = function () {
|
|
|
545
532
|
|
|
546
533
|
// setState may have been called during cWM
|
|
547
534
|
if (beforeState !== this._newState) {
|
|
548
|
-
this._instance.state = this._newState ||
|
|
535
|
+
this._instance.state = this._newState || emptyObject;
|
|
549
536
|
}
|
|
550
537
|
}
|
|
551
538
|
|
|
@@ -559,7 +546,7 @@ var ReactShallowRenderer = function () {
|
|
|
559
546
|
type = element.type;
|
|
560
547
|
|
|
561
548
|
|
|
562
|
-
var oldState = this._instance.state ||
|
|
549
|
+
var oldState = this._instance.state || emptyObject;
|
|
563
550
|
var oldProps = this._instance.props;
|
|
564
551
|
|
|
565
552
|
if (oldProps !== props) {
|
|
@@ -586,7 +573,7 @@ var ReactShallowRenderer = function () {
|
|
|
586
573
|
} else if (typeof this._instance.shouldComponentUpdate === 'function') {
|
|
587
574
|
shouldUpdate = !!this._instance.shouldComponentUpdate(props, state, context);
|
|
588
575
|
} else if (type.prototype && type.prototype.isPureReactComponent) {
|
|
589
|
-
shouldUpdate = !
|
|
576
|
+
shouldUpdate = !shallowEqual(oldProps, props) || !shallowEqual(oldState, state);
|
|
590
577
|
}
|
|
591
578
|
|
|
592
579
|
if (shouldUpdate) {
|
|
@@ -720,7 +707,7 @@ function getStackAddendum() {
|
|
|
720
707
|
if (currentlyValidatingElement) {
|
|
721
708
|
var name = getDisplayName(currentlyValidatingElement);
|
|
722
709
|
var owner = currentlyValidatingElement._owner;
|
|
723
|
-
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner));
|
|
710
|
+
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
|
724
711
|
}
|
|
725
712
|
return stack;
|
|
726
713
|
}
|
|
@@ -736,7 +723,7 @@ function shouldConstruct(Component) {
|
|
|
736
723
|
|
|
737
724
|
function getMaskedContext(contextTypes, unmaskedContext) {
|
|
738
725
|
if (!contextTypes) {
|
|
739
|
-
return
|
|
726
|
+
return emptyObject;
|
|
740
727
|
}
|
|
741
728
|
var context = {};
|
|
742
729
|
for (var key in contextTypes) {
|
|
@@ -755,7 +742,7 @@ var ReactShallowRenderer$3 = ( ReactShallowRenderer$2 && ReactShallowRenderer )
|
|
|
755
742
|
|
|
756
743
|
// TODO: decide on the top-level export form.
|
|
757
744
|
// This is hacky but makes it work with both Rollup and Jest.
|
|
758
|
-
var shallow = ReactShallowRenderer$3.default
|
|
745
|
+
var shallow = ReactShallowRenderer$3.default || ReactShallowRenderer$3;
|
|
759
746
|
|
|
760
747
|
return shallow;
|
|
761
748
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.5.0
|
|
2
2
|
* react-test-renderer-shallow.production.min.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -6,17 +6,17 @@
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
'use strict';(function(
|
|
10
|
-
f)}function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function(){function a(){
|
|
14
|
-
"");"string"===typeof b.type?
|
|
15
|
-
this._context,this._updater),this._updateStateFromStaticLifecycle(b.props),b.type.hasOwnProperty("contextTypes"),this._mountClassComponent(b,this._context)):this._rendered=b.type(b.props,this._context));this._rendering=!1;this._updater._invokeCallbacks();return this.getRenderOutput()}};a.prototype.unmount=function(){this._instance&&"function"===typeof this._instance.componentWillUnmount&&this._instance.componentWillUnmount();this._instance=this._rendered=this._newState=this._element=this._context=
|
|
9
|
+
'use strict';(function(g,f){"object"===typeof exports&&"undefined"!==typeof module?module.exports=f(require("react")):"function"===typeof define&&define.amd?define(["react"],f):g.ReactShallowRenderer=f(g.React)})(this,function(g){function f(a,b,d,c,e,h,g,x){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 w=[d,c,e,h,g,x],f=0;a=Error(b.replace(/%s/g,function(){return w[f++]}));
|
|
10
|
+
a.name="Invariant Violation"}a.framesToPop=1;throw a;}}function n(a){for(var b=arguments.length-1,d="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=0;c<b;c++)d+="&args[]="+encodeURIComponent(arguments[c+1]);f(!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. ",d)}function q(a){if("object"===typeof a&&null!==a){var b=a.$$typeof;switch(b){case y:switch(a=a.type,a){case z:case A:case B:case C:return a;
|
|
11
|
+
default:switch(a=a&&a.$$typeof,a){case D:case p:case E:return a;default:return b}}case F:return b}}}function r(a,b){return a===b?0!==a||0!==b||1/a===1/b:a!==a&&b!==b}function t(a,b){if(r(a,b))return!0;if("object"!==typeof a||null===a||"object"!==typeof b||null===b)return!1;var d=Object.keys(a),c=Object.keys(b);if(d.length!==c.length)return!1;for(c=0;c<d.length;c++)if(!G.call(b,d[c])||!r(a[d[c]],b[d[c]]))return!1;return!0}function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");
|
|
12
|
+
}var v=g.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.assign,e="function"===typeof Symbol&&Symbol.for,y=e?Symbol.for("react.element"):60103,F=e?Symbol.for("react.portal"):60106,A=e?Symbol.for("react.fragment"):60107,C=e?Symbol.for("react.strict_mode"):60108,B=e?Symbol.for("react.profiler"):60114,E=e?Symbol.for("react.provider"):60109,D=e?Symbol.for("react.context"):60110,z=e?Symbol.for("react.async_mode"):60111,p=e?Symbol.for("react.forward_ref"):60112;e&&Symbol.for("react.placeholder");var G=
|
|
13
|
+
Object.prototype.hasOwnProperty,l={},m=function(){function a(){u(this,a);this._rendered=this._newState=this._instance=this._element=this._context=null;this._forcedUpdate=this._rendering=!1;this._updater=new H(this)}a.prototype.getMountedInstance=function(){return this._instance};a.prototype.getRenderOutput=function(){return this._rendered};a.prototype.render=function(b){var a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:l;g.isValidElement(b)?void 0:n("12","function"===typeof b?" Instead of passing a component class, make sure to instantiate it by passing it to React.createElement.":
|
|
14
|
+
"");"string"===typeof b.type?n("13",b.type):void 0;q(b)!==p&&"function"!==typeof b.type?n("249",Array.isArray(b.type)?"array":null===b.type?"null":typeof b.type):void 0;if(!this._rendering){this._rendering=!0;this._element=b;var c=b.type.contextTypes;if(c){var e={},h;for(h in c)e[h]=a[h];a=e}else a=l;this._context=a;this._instance?this._updateClassComponent(b,this._context):q(b)===p?this._rendered=b.type.render(b.props,b.ref):(a=b.type,a.prototype&&a.prototype.isReactComponent?(this._instance=new b.type(b.props,
|
|
15
|
+
this._context,this._updater),this._updateStateFromStaticLifecycle(b.props),b.type.hasOwnProperty("contextTypes"),this._mountClassComponent(b,this._context)):this._rendered=b.type.call(void 0,b.props,this._context));this._rendering=!1;this._updater._invokeCallbacks();return this.getRenderOutput()}};a.prototype.unmount=function(){this._instance&&"function"===typeof this._instance.componentWillUnmount&&this._instance.componentWillUnmount();this._instance=this._rendered=this._newState=this._element=this._context=
|
|
16
16
|
null};a.prototype._mountClassComponent=function(b,a){this._instance.context=a;this._instance.props=b.props;this._instance.state=this._instance.state||null;this._instance.updater=this._updater;if("function"===typeof this._instance.UNSAFE_componentWillMount||"function"===typeof this._instance.componentWillMount)a=this._newState,"function"!==typeof b.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillMount&&this._instance.componentWillMount(),
|
|
17
|
-
"function"===typeof this._instance.UNSAFE_componentWillMount&&this._instance.UNSAFE_componentWillMount()),a!==this._newState&&(this._instance.state=this._newState||l);this._rendered=this._instance.render()};a.prototype._updateClassComponent=function(b,a){var c=b.props,
|
|
18
|
-
this._instance.componentWillReceiveProps(c,a),"function"===typeof this._instance.UNSAFE_componentWillReceiveProps&&this._instance.UNSAFE_componentWillReceiveProps(c,a));this._updateStateFromStaticLifecycle(c);var
|
|
19
|
-
"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillUpdate&&this._instance.componentWillUpdate(c,
|
|
20
|
-
this._newState||this._instance.state;b=a.getDerivedStateFromProps.call(null,b,c);null!=b&&(c=
|
|
17
|
+
"function"===typeof this._instance.UNSAFE_componentWillMount&&this._instance.UNSAFE_componentWillMount()),a!==this._newState&&(this._instance.state=this._newState||l);this._rendered=this._instance.render()};a.prototype._updateClassComponent=function(b,a){var c=b.props,d=b.type,e=this._instance.state||l,g=this._instance.props;g!==c&&"function"!==typeof b.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillReceiveProps&&
|
|
18
|
+
this._instance.componentWillReceiveProps(c,a),"function"===typeof this._instance.UNSAFE_componentWillReceiveProps&&this._instance.UNSAFE_componentWillReceiveProps(c,a));this._updateStateFromStaticLifecycle(c);var f=this._newState||e,k=!0;this._forcedUpdate?(k=!0,this._forcedUpdate=!1):"function"===typeof this._instance.shouldComponentUpdate?k=!!this._instance.shouldComponentUpdate(c,f,a):d.prototype&&d.prototype.isPureReactComponent&&(k=!t(g,c)||!t(e,f));k&&"function"!==typeof b.type.getDerivedStateFromProps&&
|
|
19
|
+
"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillUpdate&&this._instance.componentWillUpdate(c,f,a),"function"===typeof this._instance.UNSAFE_componentWillUpdate&&this._instance.UNSAFE_componentWillUpdate(c,f,a));this._instance.context=a;this._instance.props=c;this._instance.state=f;k&&(this._rendered=this._instance.render())};a.prototype._updateStateFromStaticLifecycle=function(b){var a=this._element.type;if("function"===typeof a.getDerivedStateFromProps){var c=
|
|
20
|
+
this._newState||this._instance.state;b=a.getDerivedStateFromProps.call(null,b,c);null!=b&&(c=v({},c,b),this._instance.state=this._newState=c)}};return a}();m.createRenderer=function(){return new m};var H=function(){function a(b){u(this,a);this._renderer=b;this._callbacks=[]}a.prototype._enqueueCallback=function(a,d){"function"===typeof a&&d&&this._callbacks.push({callback:a,publicInstance:d})};a.prototype._invokeCallbacks=function(){var a=this._callbacks;this._callbacks=[];a.forEach(function(a){a.callback.call(a.publicInstance)})};
|
|
21
21
|
a.prototype.isMounted=function(a){return!!this._renderer._element};a.prototype.enqueueForceUpdate=function(a,d,c){this._enqueueCallback(d,a);this._renderer._forcedUpdate=!0;this._renderer.render(this._renderer._element,this._renderer._context)};a.prototype.enqueueReplaceState=function(a,d,c,e){this._enqueueCallback(c,a);this._renderer._newState=d;this._renderer.render(this._renderer._element,this._renderer._context)};a.prototype.enqueueSetState=function(a,d,c,e){this._enqueueCallback(c,a);c=this._renderer._newState||
|
|
22
|
-
a.state;"function"===typeof d&&(d=d.call(a,c,a.props));null!==d&&void 0!==d&&(this._renderer._newState=
|
|
22
|
+
a.state;"function"===typeof d&&(d=d.call(a,c,a.props));null!==d&&void 0!==d&&(this._renderer._newState=v({},c,d),this._renderer.render(this._renderer._element,this._renderer._context))};return a}();e=(e={default:m},m)||e;return e.default||e});
|