You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to test the decrement callback of a SpinButton, but it seems it's not called when I fire the click event on the decrement button. Am I missing something?
test(`SpinButton decrement callback should be called when clicking the decrement button`,()=>{consthandleDecrement=jest.fn();consthandleIncrement=jest.fn();consthandleChange=jest.fn();render(<SpinButtononChange={handleChange}value="20"onIncrement={handleIncrement}onDecrement={handleDecrement}incrementButtonAriaLabel="Increase value by 1"decrementButtonAriaLabel="Decrease value by 1"/>);constdecrementButton=screen.getByRole("button",{name: /decrease value by 1/i});fireEvent.click(decrementButton);expect(handleDecrement).toBeCalled();});
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey,
I'm trying to test the decrement callback of a
SpinButton
, but it seems it's not called when I fire the click event on the decrement button. Am I missing something?I've also put together a codesandbox if it proves useful: https://codesandbox.io/s/trigger-splinbutton-decrement-g918h?file=/src/Sample.test.tsx.
Versions used:
Beta Was this translation helpful? Give feedback.
All reactions