From b1600adec47a04f60e1da07d94a3ed3906ff5aee Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Thu, 14 Jun 2018 16:44:21 -0400 Subject: starter files --- .../frontend/__tests__/ResetRequest.test.js | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 finished-application/frontend/__tests__/ResetRequest.test.js (limited to 'finished-application/frontend/__tests__/ResetRequest.test.js') diff --git a/finished-application/frontend/__tests__/ResetRequest.test.js b/finished-application/frontend/__tests__/ResetRequest.test.js new file mode 100644 index 0000000..22a9508 --- /dev/null +++ b/finished-application/frontend/__tests__/ResetRequest.test.js @@ -0,0 +1,54 @@ +import { mount } from 'enzyme'; +import toJSON from 'enzyme-to-json'; +import { MockedProvider } from 'react-apollo/test-utils'; +import wait from 'waait'; +import ResetRequest, { REQUEST_RESET_MUTATION } from '../components/ResetRequest'; + +const mocks = [ + { + request: { + query: REQUEST_RESET_MUTATION, + variables: { + email: 'wesbos@gmail.com', + }, + }, + result: { + data: { + requestReset: { id: 'abc123', __typename: 'User' }, + }, + }, + }, +]; + +describe('', () => { + it('renders and matches snapshot', async () => { + const wrapper = mount( + + + + ); + const form = wrapper.find("form[data-test='ResetRequest']"); + expect(toJSON(form)).toMatchSnapshot(); + }); + + it('calls the mutation', async () => { + const wrapper = mount( + + + + ); + + wrapper.find('input').simulate('change', { + target: { value: 'wesbos@gmail.com' }, + }); + + // submit the form + const form = wrapper.find('form'); + console.log(form); + form.simulate('submit'); + + await wait(); + wrapper.update(); + expect(wrapper.find('p').text()).toContain('Success! Check Your Email!'); + }); +}); -- cgit v1.3