Skip to content

Commit 9bb8a91

Browse files
committed
Review feedback
1 parent b139bcb commit 9bb8a91

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

packages/enzyme-adapter-react-13/src/ReactThirteenElementToTree.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function elementToTree(el) {
2323
let rendered = null;
2424
if (Array.isArray(children)) {
2525
rendered = flatten(children, true).map(elementToTree);
26-
} else if (children !== undefined) {
26+
} else if (typeof children !== 'undefined') {
2727
rendered = elementToTree(children);
2828
}
2929
return {

packages/enzyme-adapter-utils/src/Utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export function elementToTree(el) {
104104
let rendered = null;
105105
if (Array.isArray(children)) {
106106
rendered = flatten(children, true).map(elementToTree);
107-
} else if (children !== undefined) {
107+
} else if (typeof children !== 'undefined') {
108108
rendered = elementToTree(children);
109109
}
110110
return {

packages/enzyme/src/RSTTraversal.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ export function treeFilter(tree, fn) {
4040
* To support sibling selectors we need to be able to find
4141
* the siblings of a node. The easiest way to do that is find
4242
* the parent of the node and access its children.
43-
*
43+
*
4444
* This would be unneeded if the RST spec included sibling pointers
4545
* such as node.nextSibling and node.prevSibling
46-
* @param {*} root
47-
* @param {*} targetNode
46+
* @param {*} root
47+
* @param {*} targetNode
4848
*/
4949
export function findParentNode(root, targetNode) {
5050
const results = treeFilter(
@@ -113,7 +113,7 @@ export function nodeMatchesObjectProps(node, props) {
113113
}
114114

115115
export function getTextFromNode(node) {
116-
if (node === null || node === undefined) {
116+
if (node == null) {
117117
return '';
118118
}
119119

packages/enzyme/src/ReactWrapper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ class ReactWrapper {
611611
throw new Error('ReactWrapper::state() can only be called on the root');
612612
}
613613
const _state = this.single('state', () => this.instance().state);
614-
if (name !== undefined) {
614+
if (typeof name !== 'undefined') {
615615
return _state[name];
616616
}
617617
return _state;
@@ -635,7 +635,7 @@ class ReactWrapper {
635635
throw new Error('ReactWrapper::context() can only be called on components with instances');
636636
}
637637
const _context = instance.context;
638-
if (name !== undefined) {
638+
if (typeof name !== 'undefined') {
639639
return _context[name];
640640
}
641641
return _context;

packages/enzyme/src/ShallowWrapper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ class ShallowWrapper {
699699
throw new Error('ShallowWrapper::state() can only be called on class components');
700700
}
701701
const _state = this.single('state', () => this.instance().state);
702-
if (name !== undefined) {
702+
if (typeof name !== 'undefined') {
703703
return _state[name];
704704
}
705705
return _state;

packages/enzyme/src/Utils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function isCustomComponentElement(inst, adapter) {
2525
function propsOfNode(node) {
2626
return entries((node && node.props) || {})
2727
.filter(([, value]) => typeof value !== 'undefined')
28-
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
28+
.reduce((acc, [key, value]) => Object.assign(acc, { [key]: value }), {});
2929
}
3030

3131
export function typeOfNode(node) {
@@ -141,7 +141,7 @@ function childrenToArray(children) {
141141
const result = [];
142142

143143
const push = (el) => {
144-
if (el === null || el === false || el === undefined) return;
144+
if (el === null || el === false || typeof el === 'undefined') return;
145145
result.push(el);
146146
};
147147

@@ -161,7 +161,7 @@ export function childrenToSimplifiedArray(nodeChildren) {
161161
const child = childrenArray[i];
162162
const previousChild = simplifiedArray.pop();
163163

164-
if (previousChild === undefined) {
164+
if (typeof previousChild === 'undefined') {
165165
simplifiedArray.push(child);
166166
} else if (isTextualNode(child) && isTextualNode(previousChild)) {
167167
simplifiedArray.push(previousChild + child);
@@ -220,11 +220,11 @@ export function nodeHasProperty(node, propKey, propValue) {
220220
}
221221
const nodePropValue = nodeProps[propKey];
222222

223-
if (nodePropValue === undefined) {
223+
if (typeof nodePropValue === 'undefined') {
224224
return false;
225225
}
226226

227-
if (propValue !== undefined) {
227+
if (typeof propValue !== 'undefined') {
228228
return is(nodePropValue, propValue);
229229
}
230230

packages/enzyme/src/selectors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export function buildPredicate(selector) {
142142
// If the selector is an non-empty object, treat the keys/values as props
143143
if (typeof selector === 'object') {
144144
if (!Array.isArray(selector) && selector !== null && !isEmpty(selector)) {
145-
const hasUndefinedValues = values(selector).some(value => value === undefined);
145+
const hasUndefinedValues = values(selector).some(value => typeof value === 'undefined');
146146
if (hasUndefinedValues) {
147147
throw new TypeError('Enzyme::Props can’t have `undefined` values. Try using ‘findWhere()’ instead.');
148148
}

0 commit comments

Comments
 (0)