Skip to content

Commit

Permalink
[ReactFinalForm.js]: Add a test for 100% test coverage (final-form#307)
Browse files Browse the repository at this point in the history
* chore(contributing.md): Fix word spacing

* test(ReactFinalForm): Test events without preventDefault or stopPropagation
  • Loading branch information
Sam Kvale authored and erikras committed Jul 23, 2018
1 parent dec9c7e commit 90459e7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ We are open to, and grateful for, any contributions made by the community.
## Reporting issues and asking questions

Before opening an issue, please search
the[issue tracker](https://github.com/final-form/react-final-form/issues) to
the [issue tracker](https://github.com/final-form/react-final-form/issues) to
make sure your issue hasn’t already been reported.

**We use the issue tracker to keep track of bugs and improvements** to 🏁 React
Expand Down
22 changes: 22 additions & 0 deletions src/ReactFinalForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,28 @@ describe('ReactFinalForm', () => {
TestUtils.Simulate.submit(form)
expect(onSubmit).toHaveBeenCalled()
})
it('does not throw if handleSubmit event preventDefault or stopPropagation are not functions', () => {
const onSubmit = jest.fn()
const dom = TestUtils.renderIntoDocument(
<Form onSubmit={onSubmit}>
{({ handleSubmit }) => (
<form
onSubmit={() => {
handleSubmit({
preventDefault: undefined,
stopPropagation: undefined
})
}}
>
<Field name="foo" component="input" />
</form>
)}
</Form>
)
const form = TestUtils.findRenderedDOMComponentWithTag(dom, 'form')
TestUtils.Simulate.submit(form)
expect(onSubmit).toHaveBeenCalled()
})
it('should reinitialize when initialValues prop changes', () => {
const renderInput = jest.fn(({ input }) => <input {...input} />)
class Container extends React.Component {
Expand Down

0 comments on commit 90459e7

Please sign in to comment.