Created
March 17, 2017 05:02
-
-
Save wyqydsyq/f4bf2fb73d85554405e951cfbfa34be3 to your computer and use it in GitHub Desktop.
Enzyme + MUI
This file contains hidden or 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
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