I'm trying to come up with a way to test a component method that makes use of a helper function, like so:
handleUserClick = e => {
this.setState({ somePieceOfState: e.target.value }, () => {
someHelperFn(e.target.value);
});
}
This is a bit of a crude example, but basically right now I have code coverage (Jest) for the entire component except the line where the helper function is being called. I don't see how importing the helper function separately into the test file could help either, so I'm stumped.
EDIT: I'm asking this as a broad question for how to test components that make use of helper functions or functions that are not component methods, not specifically for that^ example above.
Upon request, here is a closer look at the function being called:
const someHelperFn = params => {
const BASE_URL = '/api/public/log-client-event';
const queryString = generateQueryString(params);
const logClientRequest = new XMLHttpRequest();
logClientRequest.open('GET', `${BASE_URL}${queryString}`);
logClientRequest.send();
return logClientRequest;
};
It is not returning a value. It just seems like Jest is complaining because it exists within the React component and there's no way to actually test it (that I know of).