Skip to content

Commit

Permalink
Wordsmithing, minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Apr 14, 2017
1 parent 8bb29d3 commit cc8ca86
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/isomorphic/classic/element/ReactElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ var ReactElement = function(type, key, ref, self, source, owner, props) {
writable: false,
value: source,
});
// Prevent the _owner attribute from breaking shallow renderer tests.
// _owner attribute would break shallow renderer equality checks.
Object.defineProperty(element, '_owner', {
configurable: false,
enumerable: false,
Expand Down
27 changes: 11 additions & 16 deletions src/renderers/testing/ReactShallowRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,41 @@

'use strict';

var React = require('react');
var ReactTestRenderer = require('ReactTestRenderer');
const React = require('react');
const ReactTestRenderer = require('ReactTestRenderer');

var emptyObject = require('fbjs/lib/emptyObject');
var getNextDebugID = require('getNextDebugID');
var invariant = require('fbjs/lib/invariant');
const emptyFunction = require('fbjs/lib/emptyFunction');
const emptyObject = require('fbjs/lib/emptyObject');
const getNextDebugID = require('getNextDebugID');
const invariant = require('fbjs/lib/invariant');

const ShallowNodeMockComponent = ({children}) => {
return children ? React.Children.toArray(children) : [];
};
const ShallowNodeMockComponent = ({children}) => React.Children.toArray(children);

function createShallowNodeMock() {
var isFirst = true;
return element => {
let isFirst = true;
return function createNodeMock(element) {
if (isFirst) {
isFirst = false;
return element.type;
}
return ShallowNodeMockComponent;
};
}
}

function wrapElementWithContextProvider(element, context) {
function noop() {}

const childContextTypes = Object.keys(context).reduce(
(context, key) => {
context[key] = noop;
context[key] = emptyFunction;
return context;
},
{},
);

class ShallowRendererWrapper extends React.Component {
static childContextTypes = childContextTypes;

getChildContext() {
return context;
}

render() {
return this.props.children;
}
Expand Down

0 comments on commit cc8ca86

Please sign in to comment.