Skip to content

Instantly share code, notes, and snippets.

@asifsaho
Created July 15, 2019 12:49
Show Gist options
  • Save asifsaho/ed39a35a00ede3501421cab37a1cd4f8 to your computer and use it in GitHub Desktop.
Save asifsaho/ed39a35a00ede3501421cab37a1cd4f8 to your computer and use it in GitHub Desktop.
import { mount } from 'enzyme';
import React from 'react';
import InputField from './index';
function setup() {
const props = {
label: 'FieldLabel',
name: 'fieldName',
onChange: jest.fn(),
value: 'fieldValue'
};
return {
props,
wrapper: mount(<InputField {...props} />)
};
}
describe('Test for InputField Component', () => {
it('Should call onChange method on changing value in input field', () => {
const component = setup();
component.wrapper
.find('input')
.simulate('change', { target: { value: 'Something' } });
expect(component.props.onChange).toHaveBeenCalled();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment