blob: da03f0c0a2c14d536dd7663a8226da98d6a21015 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import React from 'react';
import { shallow, mount } from 'enzyme';
import toJSON from 'enzyme-to-json';
import { RemoveFromCart } from '../components/RemoveFromCart';
describe('<RemoveFromCart/>', () => {
it('renders and matches snapshot', () => {
const wrapper = shallow(<RemoveFromCart id="abc123" removeFromCart={() => {}} />);
expect(toJSON(wrapper)).toMatchSnapshot();
});
it("runs a function when it's clicked", () => {
const removeSpy = jest.fn();
const wrapper = shallow(<RemoveFromCart id="abc123" removeFromCart={removeSpy} />);
wrapper.simulate('click');
expect(removeSpy).toHaveBeenCalledWith({ variables: { id: 'abc123' } });
});
});
|