mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-30 05:23:53 +03:00
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
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/stories/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();
|
|
});
|
|
});
|