Created
July 21, 2021 16:36
-
-
Save OlivierJM/9ddf760a498ecde0acd8d7b9da1449cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as actions from "../actions/"; | |
import * as types from "../utils/types"; | |
import { moviesMock } from "../utils/moviemock"; | |
describe("actions", () => { | |
it("should create an action to fetch popular movies", () => { | |
const fetchMovieAction = { | |
type: types.FETCH_POPULAR_MOVIES, | |
movies: moviesMock | |
}; | |
expect(actions.fetchPopularMovies(moviesMock)).toEqual(fetchMovieAction); | |
}); | |
it("should create an action to find details of a given movie", () => { | |
const movieDetailAction = { | |
type: types.FETCH_MOVIES_DETAILS, | |
details: moviesMock[0] | |
}; | |
expect(actions.fetchMovieDetails(moviesMock[0])).toEqual(movieDetailAction); | |
}); | |
it("should create an action to search for movies", () => { | |
const searchAction = { | |
type: types.SEARCH_MOVIES, | |
movies: moviesMock | |
}; | |
expect(actions.searchMovie(moviesMock)).toEqual(searchAction); | |
}); | |
it("should create an action to handle errors", () => { | |
const error = "something wrong happened"; | |
const errorAction = { | |
type: types.ERROR_FETCHING, | |
error | |
}; | |
expect(actions.errorFetching(error)).toEqual(errorAction); | |
}); | |
it("should create an action for loading status", () => { | |
const fetchingAction = { | |
type: types.FETCH_LOADING | |
}; | |
expect(actions.fetching()).toEqual(fetchingAction); | |
}); | |
}); |
Author
OlivierJM
commented
Jul 21, 2021
•
//moviesMock
import { Movie } from "./types";
type genre = {
id: number;
name: string;
};
const moviesMock: Movie[] = [
{
vote_count: 17,
id: 280960,
video: false,
vote_average: 5.4,
title: "Catarina and the others",
popularity: 388.325,
poster_path: "/kZMCbp0o46Tsg43omSHNHJKNTx9.jpg",
original_language: "pt",
original_title: "Catarina e os Outros",
genre_ids: [18, 9648],
backdrop_path: "/9nDiMhvL3FtaWMsvvvzQIuq276X.jpg",
adult: false,
overview:
"Outside, the first sun rays break the dawn. Sixteen years old Catarina can't fall asleep. Inconsequently, in the big city adults are moved by desire... Catarina found she is HIV positive. She wants to drag everyone else along.",
release_date: "2011-03-01"
},
{
vote_count: 334,
id: 458156,
video: false,
vote_average: 7.5,
title: "John Wick: Chapter 3 – Parabellum",
popularity: 578.653,
poster_path: "/ziEuG1essDuWuC5lpWUaw1uXY2O.jpg",
original_language: "en",
original_title: "John Wick: Chapter 3 – Parabellum",
genre_ids: [80, 28, 53],
backdrop_path: "/kcga7xuiQVqM9WHfWnAbidxU7hd.jpg",
adult: false,
overview:
"Super-assassin John Wick returns with a $14 million price tag on his head and an army of bounty-hunting killers on his trail. After killing a member of the shadowy international assassin’s guild, the High Table, John Wick is excommunicado, but the world’s most ruthless hit men and women await his every turn.",
release_date: "2019-05-15"
}
];
const genresMock: genre[] = [
{
id: 18,
name: "Drama"
},
{
id: 80,
name: "Crime"
},
{
id: 35,
name: "Comedy"
}
];
export { moviesMock, genresMock };
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment