Skip to content

Commit

Permalink
[Tests] add passing test for .parents() across a component boundary
Browse files Browse the repository at this point in the history
Closes #1046.
  • Loading branch information
ljharb committed Sep 1, 2018
1 parent f23f85f commit 2ccacb4
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3500,6 +3500,35 @@ describeWithDOM('mount', () => {
expect(bar).to.have.lengthOf(1);
expect(bar.parents('.root')).to.have.lengthOf(1);
});

it('finds parents up a tree through a custom component boundary', () => {
class CustomForm extends React.Component {
render() {
const { children } = this.props;
return (
<form>
{children}
</form>
);
}
}

const wrapper = mount((
<div>
<CustomForm>
<input />
</CustomForm>
</div>
));

const formDown = wrapper.find('form');
expect(formDown).to.have.lengthOf(1);

const input = wrapper.find('input');
expect(input).to.have.lengthOf(1);
const formUp = input.parents('form');
expect(formUp).to.have.lengthOf(1);
});
});

describe('.parent()', () => {
Expand Down

0 comments on commit 2ccacb4

Please sign in to comment.