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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment