From 71f587ac9e1f8b79b9ed4489532f9b76dfe8eed1 Mon Sep 17 00:00:00 2001 From: Bruce Paul Date: Wed, 11 Oct 2017 15:24:00 -0700 Subject: [PATCH] fix contain and containMatchingElement to accept string values before, a string was accepted via react-element-to-jsx-string. As that is no longer being used in favor of a custom function, a string should still be accepted. --- src/reactNodeToString.js | 2 ++ test/contain.test.js | 2 ++ test/containMatchingElement.test.js | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/reactNodeToString.js b/src/reactNodeToString.js index 8e82dc7..4f6f257 100644 --- a/src/reactNodeToString.js +++ b/src/reactNodeToString.js @@ -20,6 +20,8 @@ function reactArrayToJSXString (nodes) { export default function reactNodeToString (node) { if (Array.isArray(node)) { return reactArrayToJSXString(node) + } else if (typeof node === 'string') { + return node } else { return reactElementToJSXString(node) } diff --git a/test/contain.test.js b/test/contain.test.js index 0e4b436..01a7ed2 100644 --- a/test/contain.test.js +++ b/test/contain.test.js @@ -22,6 +22,7 @@ class Fixture extends React.Component { +
  • Unknown User
  • ) @@ -35,6 +36,7 @@ describe('#contain', () => { it('passes when the actual matches the expected', (wrapper) => { expect(wrapper).to.contain() expect(wrapper).to.contain() + expect(wrapper).to.contain('Unknown User') }, { render: false }) it('passes negated when the actual does not match the expected', (wrapper) => { diff --git a/test/containMatchingElement.test.js b/test/containMatchingElement.test.js index 414aafb..8955919 100644 --- a/test/containMatchingElement.test.js +++ b/test/containMatchingElement.test.js @@ -20,6 +20,7 @@ class Fixture extends React.Component {
    • +
    • Unknown User
    ) @@ -33,6 +34,7 @@ describe('#containMatchingElement', () => { it('passes when the actual matches the expected', (wrapper) => { expect(wrapper).to.containMatchingElement() expect(wrapper).to.containMatchingElement() + expect(wrapper).to.containMatchingElement('Unknown User') }, { render: false }) it('passes negated when the actual does not match the expected', (wrapper) => {