mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-22 17:46:56 +03:00
727d753081
* stash * and those * stash * stash * stash * stash * tests * fix errors * revert * stash * fix lint * prettier
50 lines
1.3 KiB
TypeScript
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();
|
|
});
|
|
});
|