From c82293ca87c043c9928767ccb99e0988151ad50a Mon Sep 17 00:00:00 2001 From: "Curtis M. Humphrey, Ph.D" Date: Wed, 2 Mar 2016 10:50:25 -0600 Subject: [PATCH] Changed test to highlight a bug, fixed the bug in Utils/containsChildrenSubArray moved checker to another line to make linter happy Updated based on feedback from PR --- src/Utils.js | 3 ++- test/ReactWrapper-spec.js | 9 +++++++-- test/ShallowWrapper-spec.js | 9 +++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Utils.js b/src/Utils.js index a4d46ea28..2f4e7d502 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -74,7 +74,8 @@ export function nodeEqual(a, b) { export function containsChildrenSubArray(match, node, subArray) { const children = childrenOfNode(node); - return children.some((_, i) => arraysEqual(match, children.slice(i, subArray.length), subArray)); + const checker = (_, i) => arraysEqual(match, children.slice(i, i + subArray.length), subArray); + return children.some(checker); } function arraysEqual(match, left, right) { diff --git a/test/ReactWrapper-spec.js b/test/ReactWrapper-spec.js index 7441339e6..9d90e0f11 100644 --- a/test/ReactWrapper-spec.js +++ b/test/ReactWrapper-spec.js @@ -138,13 +138,18 @@ describeWithDOM('mount', () => {
Goodbye
, ]; - const passes = [ + const passes1 = [ Hello,
Goodbye
, ]; + const passes2 = [ +
Goodbye
, + More, + ]; expect(wrapper.contains(fails)).to.equal(false); - expect(wrapper.contains(passes)).to.equal(true); + expect(wrapper.contains(passes1)).to.equal(true); + expect(wrapper.contains(passes2)).to.equal(true); }); }); diff --git a/test/ShallowWrapper-spec.js b/test/ShallowWrapper-spec.js index 4d7cb0762..7ba986a81 100644 --- a/test/ShallowWrapper-spec.js +++ b/test/ShallowWrapper-spec.js @@ -144,13 +144,18 @@ describe('shallow', () => {
Goodbye
, ]; - const passes = [ + const passes1 = [ Hello,
Goodbye
, ]; + const passes2 = [ +
Goodbye
, + More, + ]; expect(wrapper.contains(fails)).to.equal(false); - expect(wrapper.contains(passes)).to.equal(true); + expect(wrapper.contains(passes1)).to.equal(true); + expect(wrapper.contains(passes2)).to.equal(true); }); });