Last active
August 29, 2015 14:05
-
-
Save asbjornenge/2779930743a8000c6dab to your computer and use it in GitHub Desktop.
React test utils wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var React = require('react') | |
var ReactAddons = require('react/addons') | |
var ReactTestUtils = React.addons.TestUtils | |
var reactTestQueryUtil = function (tree) { | |
this.tree = tree | |
} | |
reactTestQueryUtil.prototype.class = function (cls) { | |
this.class = cls | |
return this | |
} | |
reactTestQueryUtil.prototype.one = function () { | |
if (this.class) return ReactTestUtils.findRenderedDOMComponentWithClass(this.tree, this.class) | |
} | |
reactTestQueryUtil.prototype.all = function () { | |
if (this.class) return ReactTestUtils.scryRenderedDOMComponentsWithClass(this.tree, this.class) | |
} | |
module.exports = function(tree) { return new reactTestQueryUtil(tree) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I made a module https://github.com/asbjornenge/react-test-query 🐵