Skip to content

Commit 2ccacb4

Browse files
committed
[Tests] add passing test for .parents() across a component boundary
Closes #1046.
1 parent f23f85f commit 2ccacb4

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

packages/enzyme-test-suite/test/ReactWrapper-spec.jsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3500,6 +3500,35 @@ describeWithDOM('mount', () => {
35003500
expect(bar).to.have.lengthOf(1);
35013501
expect(bar.parents('.root')).to.have.lengthOf(1);
35023502
});
3503+
3504+
it('finds parents up a tree through a custom component boundary', () => {
3505+
class CustomForm extends React.Component {
3506+
render() {
3507+
const { children } = this.props;
3508+
return (
3509+
<form>
3510+
{children}
3511+
</form>
3512+
);
3513+
}
3514+
}
3515+
3516+
const wrapper = mount((
3517+
<div>
3518+
<CustomForm>
3519+
<input />
3520+
</CustomForm>
3521+
</div>
3522+
));
3523+
3524+
const formDown = wrapper.find('form');
3525+
expect(formDown).to.have.lengthOf(1);
3526+
3527+
const input = wrapper.find('input');
3528+
expect(input).to.have.lengthOf(1);
3529+
const formUp = input.parents('form');
3530+
expect(formUp).to.have.lengthOf(1);
3531+
});
35033532
});
35043533

35053534
describe('.parent()', () => {

0 commit comments

Comments
 (0)