Skip to content

Instantly share code, notes, and snippets.

@kvendrik
Created November 7, 2018 18:16
Show Gist options
  • Select an option

  • Save kvendrik/aebc0e88e94e38e0d3a840689a2903e1 to your computer and use it in GitHub Desktop.

Select an option

Save kvendrik/aebc0e88e94e38e0d3a840689a2903e1 to your computer and use it in GitHub Desktop.
TextField tests - onChange() trigger
import {trigger} from '@shopify/enzyme-utilities';
...
describe('onChange()', () => {
it('triggers when the user types', () => {
const onChangeSpy = jest.fn();
const event = {};
const textField = mount(
<TextField {...mockProps} onChange={onChangeSpy} />,
);
trigger(textField.find('input'), 'onChange', event);
expect(onChangeSpy).toHaveBeenCalledTimes(1);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment