Skip to content

Instantly share code, notes, and snippets.

@dferber90
Created May 18, 2018 04:53
Show Gist options
  • Save dferber90/88630dcdaeb3e2a8de7adaf72973b93a to your computer and use it in GitHub Desktop.
Save dferber90/88630dcdaeb3e2a8de7adaf72973b93a to your computer and use it in GitHub Desktop.
Test a Render Prop!
import { shallow } from 'enzyme'
describe('when the mouse moves', () => {
const renderMock = jest.fn();
const wrapper = shallow(<Mouse render={renderMock} />);
wrapper.find('div').simulate('mousemove', {
clientX: 50,
clientY: 20,
});
it('should call `render` with the mouse coordinates', () => {
expect(renderMock).toHaveBeenCalledWith({ x: 50, y: 20 });
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment