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

Thomas John
- 2,138
- 2
- 22
- 38
-
1Do 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
-
1Hmm, 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 Answers
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