Skip to content

Instantly share code, notes, and snippets.

@jhollingworth
Created May 19, 2015 16:14
Show Gist options
  • Save jhollingworth/b10eda7788ef60b05037 to your computer and use it in GitHub Desktop.
Save jhollingworth/b10eda7788ef60b05037 to your computer and use it in GitHub Desktop.
let testTree = require('react-test-tree');
class Bar extends React.Component {
render() {
return (
<div className="Bar">
<span className="Bar-name" ref="name">
{this.props.name}
</span>
</div>
);
}
}
class Foo extends React.Component {
render() {
return (
<div className="Foo" refCollection="bars">
{this.props.bars.map(bar => <Bar name={bar.name} />)}
</div>
);
}
}
let bars = [{ name: "foo" }, { name: "bar" }, { name: "baz"}];
let foo = testTree(<Foo bars={bars} />);
expect(foo.bars[1].name.innerText).to.eql("bar");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment