Skip to content

Instantly share code, notes, and snippets.

@fakiolinho
Created March 13, 2018 12:57
Show Gist options
  • Save fakiolinho/aacdce0151a987cbd5ecdf70cf49d9c3 to your computer and use it in GitHub Desktop.
Save fakiolinho/aacdce0151a987cbd5ecdf70cf49d9c3 to your computer and use it in GitHub Desktop.
import React from 'react';
import { shallow } from 'enzyme';
import Options from './';
describe('test Options component', () => {
it('instance method handleAdd should be triggered when add button gets clicked', () => {
const enzymeWrapper = shallow(<Options />);
enzymeWrapper.instance().handleAdd = jest.fn();
enzymeWrapper.find('[data-test="add"]').simulate('click');
expect(enzymeWrapper.instance().handleAdd).toHaveBeenCalledTimes(1);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment