I am trying to use jest to test an async action creator that fetches some data. I have scavenged through the redux-mock-store documentation but I actually did not grasp what I should do. Here is action:
import { Dispatch } from 'redux';
export interface Task {
id: string;
title: string;
categoryTitle?: string;
error?: null;
}
export interface Category {
name: string,
tasks: Task[]
}
export const getCategories = () => {
return async (dispatch: Dispatch) => {
const response = await axios.get<Category[]>(url);
dispatch<GetCategoriesAction>({
type: ActionTypes.getCategories,
payload: response.data
});
};
};
How can I test it? Can someone guide me through the steps?
Aucun commentaire:
Enregistrer un commentaire