jeudi 31 octobre 2019

Test Nested Tag attribute inside Parent Tag's attribute

I have a tag that is nested inside another tag's attribute.

Exhibit a.

<Tag
    input={(
      <NestedTag
        value={this.props.value}
        onChange={this.validate}
      />
    )}
  />

What I want to do is check that value inside NestedTag is correct.

In Enzyme, I've got as far as this:

expect(
  wrap
    .find(Tag)
    .at(0)
    .prop('input')
).toBe(...tag info goes here);

This is as far as I've gotten so far. I just don't know how to look inside "input" and poke around inside NestedTag.

I know I can use toMatchObject, but I've prefer to check each individual property in isolation.

Aucun commentaire:

Enregistrer un commentaire