react-test-renderer
Advanced tools
Comparing version 16.0.0-alpha.13 to 16.0.0-beta.1
'use strict'; | ||
var objectAssign$1 = require('object-assign'); | ||
if (process.env.NODE_ENV !== "production") { | ||
'use strict'; | ||
var objectAssign = require('object-assign'); | ||
var checkPropTypes = require('prop-types/checkPropTypes'); | ||
@@ -21,18 +26,54 @@ var react = require('react'); | ||
var ReactInternals = react.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
/** | ||
* Copyright 2016-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* | ||
* @providesModule describeComponentFrame | ||
*/ | ||
var ReactGlobalSharedState = { | ||
ReactCurrentOwner: ReactInternals.ReactCurrentOwner | ||
var describeComponentFrame$1 = function (name, source, ownerName) { | ||
return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : ''); | ||
}; | ||
{ | ||
objectAssign$1(ReactGlobalSharedState, { | ||
ReactComponentTreeHook: ReactInternals.ReactComponentTreeHook, | ||
ReactDebugCurrentFrame: ReactInternals.ReactDebugCurrentFrame | ||
}); | ||
/** | ||
* Copyright 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @providesModule getComponentName | ||
* | ||
*/ | ||
function getComponentName$1(instanceOrFiber) { | ||
if (typeof instanceOrFiber.getName === 'function') { | ||
// Stack reconciler | ||
var instance = instanceOrFiber; | ||
return instance.getName(); | ||
} | ||
if (typeof instanceOrFiber.tag === 'number') { | ||
// Fiber reconciler | ||
var fiber = instanceOrFiber; | ||
var type = fiber.type; | ||
if (typeof type === 'string') { | ||
return type; | ||
} | ||
if (typeof type === 'function') { | ||
return type.displayName || type.name; | ||
} | ||
} | ||
return null; | ||
} | ||
var ReactGlobalSharedState_1 = ReactGlobalSharedState; | ||
var getComponentName_1 = getComponentName$1; | ||
var _extends = objectAssign$1 || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _extends = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -49,4 +90,31 @@ | ||
var ReactDebugCurrentFrame = ReactGlobalSharedState_1.ReactDebugCurrentFrame; | ||
{ | ||
var describeComponentFrame = describeComponentFrame$1; | ||
var getComponentName = getComponentName_1; | ||
var currentlyValidatingElement = null; | ||
var getDisplayName = function (element) { | ||
if (element == null) { | ||
return '#empty'; | ||
} else if (typeof element === 'string' || typeof element === 'number') { | ||
return '#text'; | ||
} else if (typeof element.type === 'string') { | ||
return element.type; | ||
} else { | ||
return element.type.displayName || element.type.name || 'Unknown'; | ||
} | ||
}; | ||
var getStackAddendum = function () { | ||
var stack = ''; | ||
if (currentlyValidatingElement) { | ||
var name = getDisplayName(currentlyValidatingElement); | ||
var owner = currentlyValidatingElement._owner; | ||
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner)); | ||
} | ||
return stack; | ||
}; | ||
} | ||
var ReactShallowRenderer = function () { | ||
@@ -94,7 +162,7 @@ function ReactShallowRenderer() { | ||
if (element.type.hasOwnProperty('contextTypes')) { | ||
ReactDebugCurrentFrame.element = element; | ||
currentlyValidatingElement = element; | ||
checkPropTypes(element.type.contextTypes, context, 'context', getName(element.type, this._instance), ReactDebugCurrentFrame.getStackAddendum); | ||
checkPropTypes(element.type.contextTypes, context, 'context', getName(element.type, this._instance), getStackAddendum); | ||
ReactDebugCurrentFrame.element = null; | ||
currentlyValidatingElement = null; | ||
} | ||
@@ -211,2 +279,6 @@ | ||
this._renderer.render(this._renderer._element, this._renderer._context); | ||
if (typeof callback === 'function') { | ||
callback.call(publicInstance); | ||
} | ||
}; | ||
@@ -217,2 +289,6 @@ | ||
this._renderer.render(this._renderer._element, this._renderer._context); | ||
if (typeof callback === 'function') { | ||
callback.call(publicInstance); | ||
} | ||
}; | ||
@@ -228,2 +304,6 @@ | ||
this._renderer.render(this._renderer._element, this._renderer._context); | ||
if (typeof callback === 'function') { | ||
callback.call(publicInstance); | ||
} | ||
}; | ||
@@ -243,4 +323,6 @@ | ||
var ReactShallowRenderer_1 = ReactShallowRenderer; | ||
var ReactShallowRendererEntry = ReactShallowRenderer; | ||
module.exports = ReactShallowRenderer_1; | ||
module.exports = ReactShallowRendererEntry; | ||
} |
{ | ||
"name": "react-test-renderer", | ||
"version": "16.0.0-alpha.13", | ||
"version": "16.0.0-beta.1", | ||
"description": "React package for snapshot testing.", | ||
@@ -22,3 +22,3 @@ "main": "index.js", | ||
"peerDependencies": { | ||
"react": "^16.0.0-alpha.13" | ||
"react": "^16.0.0-beta.1" | ||
}, | ||
@@ -25,0 +25,0 @@ "files": [ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
307536
7305
6