- Notifications
You must be signed in to change notification settings - Fork2.8k
-
Hey, I'm trying to test the decrement callback of a 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:/decreasevalueby1/i});fireEvent.click(decrementButton);expect(handleDecrement).toBeCalled();}); 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: "dependencies": {"@fluentui/react":"7.128.1","@testing-library/react":"11.2.5","react":"16.13.0","react-dom":"16.13.0","react-scripts":"3.4.1" },"devDependencies": {"@types/react":"16.13.0","@types/react-dom":"16.13.0","typescript":"4.1.3" }, |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment
-
Hey@mccuna, have you checked test files of SpinButton, they should have increment/decrement:https://github.com/microsoft/fluentui/blob/master/packages/react-components/react-spinbutton/library/src/components/SpinButton/SpinButton.test.tsx |
BetaWas this translation helpful?Give feedback.
All reactions
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment