-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass min and max to number input form field
- Loading branch information
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@toptal/picasso-forms': patch | ||
--- | ||
|
||
- pass min and max to number input in forms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react' | ||
import { render } from '@toptal/picasso-test-utils' | ||
|
||
import { FormCompound as Form } from '../FormCompound' | ||
import { NumberInput, type Props } from './NumberInput' | ||
|
||
const numberInputMock = jest.fn() | ||
|
||
jest.mock('@toptal/picasso-number-input', () => ({ | ||
...jest.requireActual('@toptal/picasso-number-input'), | ||
NumberInput: (props: any) => numberInputMock(props), | ||
})) | ||
|
||
const renderFormWithNumberInput = (props: Props) => | ||
render( | ||
<Form.ConfigProvider value={{}}> | ||
<Form onSubmit={() => {}}> | ||
<NumberInput label='Test' data-testid='number-input' {...props} /> | ||
</Form> | ||
</Form.ConfigProvider> | ||
) | ||
|
||
describe('Form.NumberInput', () => { | ||
describe('when "min" and "max" props are provided', () => { | ||
it('passes them to NumberInput', () => { | ||
renderFormWithNumberInput({ | ||
min: '8', | ||
max: '12', | ||
name: 'test-input', | ||
}) | ||
|
||
expect(numberInputMock).toHaveBeenCalledTimes(1) | ||
expect(numberInputMock).toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
min: '8', | ||
max: '12', | ||
name: 'test-input', | ||
}) | ||
) | ||
}) | ||
}) | ||
}) |