Skip to content

Instantly share code, notes, and snippets.

@wyqydsyq
Created March 17, 2017 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wyqydsyq/f4bf2fb73d85554405e951cfbfa34be3 to your computer and use it in GitHub Desktop.
Save wyqydsyq/f4bf2fb73d85554405e951cfbfa34be3 to your computer and use it in GitHub Desktop.
Enzyme + MUI
import * as React from 'react'
import * as enzyme from 'enzyme'
import * as sinon from 'sinon'
import * as dom from 'jsdom'
import getMuiTheme from 'material-ui/styles/getMuiTheme'
import MyDialog from './MyDialog'
global['document'] = dom.jsdom('<html></html>')
global['window'] = global['document'].defaultView
test('Clicking an action button fires actionOnClickFn', () => {
const resetFn = sinon.stub()
const handleInputFn = sinon.stub()
const actionOnClickFn = sinon.stub()
const handleCloseFn = sinon.stub()
const muiTheme = getMuiTheme()
const dialog = enzyme.mount(
(
<MyDialog />
), {
context: { muiTheme },
childContextTypes: {
muiTheme: React.PropTypes.object
}
}
)
dialog.find('button.send-email').simulate('click')
expect(sinon.assert.calledOnce(actionOnClickFn)).toBe(true)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment