diff --git a/src/components/range-editor/range-editor.test.tsx b/src/components/range-editor/range-editor.test.tsx new file mode 100644 index 000000000..04db32b31 --- /dev/null +++ b/src/components/range-editor/range-editor.test.tsx @@ -0,0 +1,27 @@ +import '@testing-library/jest-dom'; +import React from "react" +import { render, screen } from "../../test-utils" +import userEvent from '@testing-library/user-event' +import RangeEditor from "./range-editor" +import { expect, it, vi } from "vitest" + +it('can enter negative value to a numeric input', async () => { + const mockOnChangeFn = vi.fn() + const user = userEvent.setup() + + render( + + ) + + const numberInput = screen.getByRole('spinbutton') + expect(numberInput).toBeInTheDocument() + + await user.clear(numberInput) + await user.type(numberInput, '-5') + await user.tab() + + expect(mockOnChangeFn).toHaveBeenCalledWith(-5) +}) diff --git a/src/components/range-editor/range-editor.tsx b/src/components/range-editor/range-editor.tsx index 68065cded..9d87da4b1 100644 --- a/src/components/range-editor/range-editor.tsx +++ b/src/components/range-editor/range-editor.tsx @@ -43,7 +43,7 @@ const RangeEditor: FunctionComponent setCurrentValue(e.target.valueAsNumber)} onBlur={() => onChange(currentValue)}