Skip to content

Instantly share code, notes, and snippets.

@nicolasiensen
Created December 20, 2016 11:38
Show Gist options
  • Save nicolasiensen/730f6b438ecc0140faa234b6818e88e6 to your computer and use it in GitHub Desktop.
Save nicolasiensen/730f6b438ecc0140faa234b6818e88e6 to your computer and use it in GitHub Desktop.
Simulating events with Jest and Material UI
// 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