2

This is what my jsx file contains, {' '+this.props.file.attached.name} How can I write test for this name ?

Thomas John
  • 2,138
  • 2
  • 22
  • 38
  • 1
    Do a select against the element that contains that as it's child and check it's inner text? – ctrlplusb Sep 22 '16 at 09:11
  • `expect(wrapper.find('.attachedFile').text()).to.equal(' apple');` is this what you meant? I got an assertion error undefined to equal apple – Thomas John Sep 22 '16 at 09:30
  • 1
    Hmm, not sure if the `text` prop works for a specific node. Try this type of approach: `expect(wrapper.containsMatchingElement(
    apple
    )).to.equal(true)`
    – ctrlplusb Sep 22 '16 at 09:35

1 Answers1

1
expect(wrapper.containsMatchingElement([<div class="attachedFile"><i class="fa fa-file-image-o"></i>  apple</div>])).to.equal(true);

This works perfect,ensure that you surround the elements with []

Thomas John
  • 2,138
  • 2
  • 22
  • 38