blob: 0b1de749d1e3267c180d8878c4d460e9e7672588 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import React from 'react';
import { shallow, mount } from 'enzyme';
import toJSON from 'enzyme-to-json';
import RemoveFromCart from '../components/RemoveFromCart';
import mountOptions from './mockMang';
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' } });
});
});
|