Skip to content

Instantly share code, notes, and snippets.

@jhollingworth
Created May 19, 2015 16:15
Show Gist options
  • Save jhollingworth/8d058ae8e65351854a85 to your computer and use it in GitHub Desktop.
Save jhollingworth/8d058ae8e65351854a85 to your computer and use it in GitHub Desktop.
let testTree = require('react-test-tree');
class Foo extends React.Component {
render() {
return (
<div className="Foo">
<Bar ref="bar1" />
<Bar ref="bar2" />
</div>
);
}
}
class Bar extends React.Component {
render() {
return (
<div className="Bar">
<Baz ref="baz" />
</div>
);
}
}
class Baz extends React.Component {
render() {
return <div className="Baz" />;
}
}
let foo = testTree(<Foo />, {
stub: {
bar1: null, // Don't render this component,
bar2: {
baz: <div />, // render div instead
}
}
});
expect(foo.bar1).to.not.exist;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment