Skip to content

Commit

Permalink
add test for context emptyValue
Browse files Browse the repository at this point in the history
  • Loading branch information
joakbjerk committed Jul 2, 2024
1 parent 4b3b64e commit b3723e8
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,29 @@ describe('Field.Number', () => {
log.mockRestore()
})
})

it('should use emptyValue when not set in data context', () => {
const onSubmit = jest.fn()
render(
<Form.Handler data={{}} onSubmit={onSubmit}>
<Field.Number
label="Label"
value={0}
path="/myValue"
emptyValue={0}
/>
</Form.Handler>
)

const form = document.querySelector('form')
fireEvent.submit(form)

expect(onSubmit).toHaveBeenCalledTimes(1)
expect(onSubmit).toHaveBeenCalledWith(
{ myValue: 0 },
expect.anything()
)
})
})

describe('event handlers', () => {
Expand Down

0 comments on commit b3723e8

Please sign in to comment.