onValueChange
prop of a controlled NumberInput
does not set value correctly in testing DOM
#2164
spatial-andrewc
started this conversation in
General
Replies: 2 comments
-
I've included another regression that occurs in the testing DOM in the provided code sandbox. This was noticed after the same upgrade. it("will fail because it accepts text", async () => {
render(<NumberFieldFailsWithText />);
const numberInput = screen.getByRole("spinbutton");
await user.type(numberInput, "~as*jhsqwr*");
await waitFor(() => expect(numberInput).toHaveValue(""));
});
|
Beta Was this translation helpful? Give feedback.
0 replies
-
And another here it("will fail because it does not respect constraints", async () => {
render(<NumberFieldPasses max={1} formatOptions={{ style: "percent" }}/>);
const numberInput = screen.getByRole("spinbutton");
await user.type(numberInput, "1000");
fireEvent.blur(numberInput);
await waitFor(() => expect(numberInput).toHaveValue("100%"));
});
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
Since upgrading to
@ark-ui/react
major version 1 I am noticing that theonValueChange
callback incorrectly sets the value of the input element in a jest DOM when using the@tesing-library/react
and@testing-library/user-event
libs. I have included a devbox that shows how the same test fails when usingonValueChange
but passes when usingonChange
.The expected behaviour is that
onValueChange
correctly sets the input value.Link to Reproduction (or Detailed Explanation)
https://codesandbox.io/p/devbox/jolly-wood-gz5djk
Steps to Reproduce
test
Ark UI Version
1.2.1
Framework
Browser
No response
Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions