Instantly share code, notes, and snippets.

Embed
What would you like to do?
react-testing-2
describe('when valid email was filled', () => {
beforeEach(() => {
subscribe = jest.fn();
wrapper = mount(<Subscription subscribe={subscribe}/>);
});
describe('and when form was submitted', () => {
beforeEach(() => {
...
wrapper.find('#email').simulate('change', {target: {name: 'email', value: 'blah@gmail.com'}});
wrapper.find('#submit').simulate('submit');
});
it('should subscribe to the news with correct email', () => {
expect(subscribe).toHaveBeenCalledWith({email: 'blah@gmail.com'});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment