Skip to content

Instantly share code, notes, and snippets.

@whtswrng
Last active October 21, 2018 10:41
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 whtswrng/17f7a8f06b0790a8b94b3321f4f180da to your computer and use it in GitHub Desktop.
Save whtswrng/17f7a8f06b0790a8b94b3321f4f180da to your computer and use it in GitHub Desktop.
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