title: Testing for text contained in React component with Enzyme and Jest
body: <p>For my React component I have the following:</p>
  
  <pre><code>const ArchiveButton = ({collection, onClick}) =&gt; {
  
      return (
          &lt;span&gt;
              { collection.archived &amp;&amp;
              &lt;Button bsStyle="link" onClick={onClick}&gt;&lt;i className="fa fa-rotate-left" /&gt;&amp;nbsp;Unarchive&lt;/Button&gt;
              }
              { !collection.archived &amp;&amp;
              &lt;Button bsStyle="link" onClick={onClick}&gt;&lt;i className="fa fa-archive" /&gt;&amp;nbsp;Archive&lt;/Button&gt;
              }
          &lt;/span&gt;
      );
  };
  </code></pre>
  
  <p>I'm attempting to test by passing in different values for <code>collection.archived</code> and I want to check for the existence of the text "Unarchive" vs "Archive". When I do a <code>wrapper.find('Button')</code> and try and check against <code>.text()</code> it is just <code>&lt;Button /&gt;</code> and the only way I've figured out how to test it is:</p>
  
  <pre><code>    const wrapper = shallow(&lt;ArchiveButton onClick={onClick} {...props}/&gt;);
  
      let button = wrapper.find('Button').prop('children');
      expect(button[1]).toMatch(/\sUnarchive/);
  </code></pre>
  
  <p>Seems a bit off though, not sure.  Thanks!</p>