Created
December 20, 2016 11:38
-
-
Save nicolasiensen/730f6b438ecc0140faa234b6818e88e6 to your computer and use it in GitHub Desktop.
Simulating events with Jest and Material UI
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
// Simulating clicks | |
const dashboardMount = mount( | |
<Dashboard />, { | |
context: { muiTheme }, | |
childContextTypes: { muiTheme: React.PropTypes.object } | |
} | |
) | |
const menuButton = ReactDOM.findDOMNode(dashboardMount.find(AppBar).find(IconButton).find('button').node) | |
TestUtils.Simulate.touchTap(menuButton) | |
expect(dashboardMount.find(Drawer).prop('open')).toBe(true) | |
const overlay = ReactDOM.findDOMNode(dashboardMount.find(Drawer).find(Overlay).find('div').node) | |
TestUtils.Simulate.touchTap(overlay) | |
expect(dashboardMount.find(Drawer).prop('open')).toBe(false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment