redux-devtools/packages/devui/tests/Form.test.tsx
Nathan Bierema 727d753081
feature(devui): convert to TypeScript (#629)
* stash

* and those

* stash

* stash

* stash

* stash

* tests

* fix errors

* revert

* stash

* fix lint

* prettier
2020-09-09 10:35:22 -04:00

50 lines
1.3 KiB
TypeScript

import React from 'react';
import { shallow, mount } from 'enzyme';
import { shallowToJson } from 'enzyme-to-json';
import { Form } from '../src';
import { schema, uiSchema, formData } from '../src/Form/schema';
describe('Form', function () {
it('renders correctly', () => {
const wrapper = shallow(
<Form formData={formData} schema={schema} uiSchema={uiSchema} />
);
expect(shallowToJson(wrapper)).toMatchSnapshot();
});
it('renders with primary button', () => {
const wrapper = shallow(
<Form
primaryButton
submitText="Custom button"
formData={formData}
schema={schema}
uiSchema={uiSchema}
/>
);
expect(shallowToJson(wrapper)).toMatchSnapshot();
});
it('renders with no button', () => {
const wrapper = shallow(
<Form formData={formData} schema={schema} uiSchema={uiSchema} noSubmit />
);
expect(shallowToJson(wrapper)).toMatchSnapshot();
});
it('should handle the submit event', () => {
const onSubmit = jest.fn();
const wrapper = mount(
<Form
formData={formData}
schema={schema}
uiSchema={uiSchema}
onSubmit={onSubmit}
/>
);
wrapper.find('form').simulate('submit');
expect(onSubmit).toBeCalled();
});
});