The enzyme does not find the component props

I have a component that I am testing with Enzyme that looks like this:

<RichTextEditor name="name" onChange={[Function]} value="<p>what</p>" focus={false}>
  <div className="rich-text-editor">
  <div className="btn-group" role="group">
  <StyleButton active={false} icon="fa-list-ul" label="UL" onToggle={[Function]} style="unordered-list-item">
  // ...

I am trying to detect the presence of a StyleButton component like this:

mount(<RichTextEditor />).find('StyleButton[label="UL"]')

But no components are returned. I can find all StyleButtons by simply searching for the "StyleButton" line, but I cannot find by property, including just using my own property selector.

The first block of code I inserted is from the debug output of the RichTextEditor installation, so StyleButton definitely exists.

Any ideas?

Thank.

+4
source share
1 answer

:

  • CSS

findWhere:

 wrapper.findWhere(n => n.name() === 'StyleButton' && n.prop('label') === 'UL')
+11

Source: https://habr.com/ru/post/1661770/


All Articles