Skip to content

Instantly share code, notes, and snippets.

View chestozo's full-sized avatar

chestozo

  • Portugal
  • 06:04 (UTC +01:00)
View GitHub Profile
@danmakenoise
danmakenoise / test.js
Last active February 29, 2024 20:23
Unit Testing Children of React Context API Consumers with Enzyme
// Component.js
const Component = props => (
<MyContext.Consumer>
{(context) => (
<Foo
bar={props.bar}
baz={context.baz}
/>
)}
</MyContext.Consumer>
var Dialog = React.createClass({
render: function() {
// 1) render nothing, this way the DOM diff will never try to do
// anything to it again, and we get a node to mess with
return React.DOM.div();
},
componentDidMount: function() {
// 2) do DOM lib stuff
this.node = this.getDOMNode();