Created
July 24, 2019 10:24
-
-
Save takahirohonda/fa1fc3909600966e23a942ec5136b3cf to your computer and use it in GitHub Desktop.
setting-up-unit-tests-for-react-with-mocha-jsdom-and-enzyme
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
import React from 'react' | |
import { expect } from 'chai' | |
import { shallow, mount } from 'enzyme' | |
import sinon from 'sinon' | |
import Form from '../Form' | |
import initialState from '../../reducers/initialState' | |
describe('<Form />', () => { | |
let state; | |
let spySubmitHandler; | |
beforeEach(() => { | |
state = initialState.information; | |
spySubmitHandler = sinon.spy(); | |
}); | |
it.only('should fire onSubmit function', () => { | |
const wrapper = mount( | |
<Form | |
information={state} | |
onSubmitHandler={spySubmitHandler} | |
/>); | |
wrapper.find('button').simulate('click'); | |
sinon.assert.calledOnce(spySubmitHandler) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment