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
}
};
//我是 Jest 的新手。我有以下文件。我需要为它编写单元测试。任何人都可以//帮助我应该如何开始或给我一个我可以编写的可能单元测试的抽象形式。