import React from 'react'; import { shallow, mount } from 'enzyme'; import toJSON from 'enzyme-to-json'; import { ApolloProvider } from 'react-apollo'; import RemoveFromCart from '../components/RemoveFromCart'; import mountOptions, { mocked, mountWithApollo } from './mockMang'; describe('', () => { it('renders and matches snapshot', () => { const wrapper = mountWithApollo(); expect(toJSON(wrapper.find('button'))).toMatchSnapshot(); }); it('runs the mutation with correct variables', () => { const wrapper = mountWithApollo(); const mutation = wrapper.find('Mutation').instance(); mutation.client.mutate = jest.fn().mockResolvedValue({ removeFromCart: { id: 'abc123' } }); wrapper.find('button').simulate('click'); expect(mutation.client.mutate).toHaveBeenCalled(); expect(mutation.client.mutate).toHaveBeenCalledWithVariables({ id: 'abc123' }); }); });