import service from "Api/service";
import { ROOT_URL, saveError } from "Api";
import {
FETCH_USER_REQUEST,
FETCH_USER_FAILURE,
FETCH_USER_SUCCESS
} from "Constants/redux";
// it fetch the details of an user
export const fetchDetails = () => {
return (dispatch, getState) => {
dispatch(fetchDetailsRequest());
return service
.get(`${ROOT_URL}/employees/list`)
.then(response => {
dispatch(fetchDetailsSuccess(response));
})
.catch(error => {
console.log(error);
saveError(error, getState());
dispatch(fetchDetailsFailure(error));
});
};
};
export const ffetchDetailsRequest = () => {
return {
type: FETCH_USER_REQUEST
}
};
export const fetchDetailsSuccess = (res) => {
return {
res,
type: FETCH_USER_SUCCESS
}
};
export const ffetchDetailsFailure = (err) => {
return {
err,
type: FETCH_USER_FAILURE
}
};
//I am new to Jest. I have below file. I need to write unit tests for it. Can anyone //help how I should start or give me an abstract form of the possible unit tests I can write.