'How to cover onIdle callback function with test react-idle-timer
I use react-idle-timer 4.6.4
I have a component with useIdleTimer hook.
import {useDispatch} from "react-redux";
import {logoutRequest} from "auth/actions";
const App = () => {
const dispatch = useDispatch();
const logout = () => dispatch(logoutRequest);
useIdleTimer({
timeout: 1000 * 60 * 5,
onIdle: logout,
debounce: 500
});
return <Component />
}
Also, I have a test that looks like this
test("render App", () => {
render(<App />);
const someElement = screen.getByText("Some element");
expect(someElement).toBeInTheDocument();
})
This test covers all lines of code except for the logout function.
How to cover the logout function with tests?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
