return async (dispatch, getState) => {
const { videos, selectedVideos } = getState().youtube;
console.table(videos);
console.table(selectedVideos);
const videoIds = videos
.filter(video => selectedVideos.includes(video.id))
.map(video => video.itemId);
console.log(playlistId, videoIds);
try {
await endorApi.youtube.deleteVideo(playlistId, videoIds);
dispatch(cleanSelected());
dispatch(getPlaylistVideos(playlistId));
} catch (err) {
dispatch(setError("Cannot delete video!"));
}
};
};
Тест:
it("delete video", () => {
const id = "a3ey8sjkd";
const store = mockStore({
youtube: {
videos: [
{
id: "c12ws",
itemId: "itmIdsqdw"
}
],
selectedVideos: ["asa", "c12ws"]
}
});
const expectedActions = [];
endorApi.youtube.deleteVideo.mockReturnValue({});
return store.dispatch(youtubeActions.deleteVideo(id)).then(() => {
console.log(store.getActions());
expect(store.getActions()).toEqual(expectedActions);
});
});
Попробуй сначала добиться минимального размера кода, который будет содержать ошибку
Обсуждают сегодня