Skip to content

Commit

Permalink
Added related tests (#5471)
Browse files Browse the repository at this point in the history
  • Loading branch information
giveerr committed Dec 25, 2023
1 parent a8d5ceb commit 646b012
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,30 @@ describe('@mantine/core/NumberInput', () => {
await enterText('{arrowdown}');
expect(spy).toHaveBeenCalledTimes(2);
});

it('checks whether the data entered is larger than Number.MAX_SAFE_INT', async () => {
const spy = jest.fn();
render(<NumberInput value={9007199254740991} onChange={spy} />);

focusInput();
await enterText('{backspace}');
expect(spy).toHaveBeenLastCalledWith(900719925474099);
expect(spy).toHaveBeenCalledTimes(1);

await enterText('2');
expect(spy).toHaveBeenLastCalledWith('9007199254740992');
expect(spy).toHaveBeenCalledTimes(2);

await enterText('7');
expect(spy).toHaveBeenLastCalledWith('90071992547409927');
expect(spy).toHaveBeenCalledTimes(3);

await enterText('{backspace}');
await enterText('{backspace}');
await enterText('{backspace}');
await enterText('{backspace}');
await enterText('{backspace}');
expect(spy).toHaveBeenLastCalledWith(900719925474);
expect(spy).toHaveBeenCalledTimes(8);
});
});

0 comments on commit 646b012

Please sign in to comment.