Skip to content

Commit

Permalink
Added test for .ref(refName)
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonbernardes committed Dec 20, 2015
1 parent aec014e commit 65931b4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/__tests__/ReactWrapper-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1158,4 +1158,23 @@ describeWithDOM('mount', () => {
});
});

describe('.ref(refName)', () => {
it('gets a wrapper of the node matching the provided refName', () => {

class Foo extends React.Component {
render() {
return (
<div>
<span ref="firstRef" amount={2}>First</span>
<span ref="secondRef" amount={4}>Second</span>
<span ref="thirdRef" amount={8}>Third</span>
</div>
);
}
}
const wrapper = mount(<Foo />);
expect(wrapper.ref('secondRef').prop('amount')).to.equal(4);
expect(wrapper.ref('secondRef').text()).to.equal('Second');
});
});
});

0 comments on commit 65931b4

Please sign in to comment.