import React from 'react'; import {NumberField} from 'app/components/forms'; import Form from 'app/components/forms/form'; import {shallow, mount} from 'enzyme'; jest.mock('jquery'); describe('NumberField', function() { describe('render()', function() { it('renders', function() { const wrapper = shallow(); expect(wrapper).toMatchSnapshot(); }); it('renders with optional attributes', function() { const wrapper = shallow(); expect(wrapper).toMatchSnapshot(); }); it('renders with value', function() { const wrapper = shallow(); expect(wrapper).toMatchSnapshot(); }); it('renders with form context', function() { const wrapper = shallow(, { context: { form: { data: { fieldName: 5, }, errors: {}, }, }, }); expect(wrapper).toMatchSnapshot(); }); it('doesnt save `NaN` when new value is empty string', function() { const wrapper = mount(
{}}> ); wrapper.find('input').simulate('change', {target: {value: ''}}); expect(wrapper.state('data').fieldName).toBe(''); }); }); });