Skip to content

Commit 12e4e92

Browse files
committed
Add test for invalid input
1 parent 167d072 commit 12e4e92

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/components/input/__tests__/Input.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,5 +259,18 @@ describe('Input', () => {
259259
rerender(<Input type="number" value={12} />);
260260
expect(input).toHaveValue(12);
261261
});
262+
263+
test('returns NaN once for invalid number', () => {
264+
const {
265+
container: {firstChild: input}
266+
} = render(
267+
<Input type="number" min={0} value={0} setProps={mockSetProps} />
268+
);
269+
270+
userEvent.type(input, '{backspace}-100');
271+
272+
expect(mockSetProps.mock.calls).toHaveLength(1);
273+
expect(mockSetProps.mock.calls[0][0]).toEqual({value: NaN});
274+
});
262275
});
263276
});

0 commit comments

Comments
 (0)