Skip to content

Instantly share code, notes, and snippets.

@huxaiphaer
Created February 10, 2020 08:28
Show Gist options
  • Save huxaiphaer/bf8e224def803a63addce8001ef63e34 to your computer and use it in GitHub Desktop.
Save huxaiphaer/bf8e224def803a63addce8001ef63e34 to your computer and use it in GitHub Desktop.
import reduxThunk from 'redux-thunk';
import * as moxios from 'moxios';
import configurestore from 'redux-mock-store';
import {APIKey, LANGUAGE,URL} from "../../utils/ApiKey";
import {fetchMovies} from "../../actions/searchActions";
import {FETCH_MOVIES} from "../../actions/types";
const middlewares = [reduxThunk];
const mockStore = configurestore(middlewares);
describe('search action', () => {
beforeEach(() => {
moxios.install();
store.clearActions();
});
});
afterEach(() => {
moxios.uninstall();
});
it('should be able to make a fetch request without fail', () => {
moxios.stubRequest(`${URL}/3/search/movie/?api_key=${APIKey}&language=${LANGUAGE}
&query=${"gemini"}`, {
status: 200,
response: {
name: 'gemini man',
id: 23
}
});
store.dispatch(fetchMovies()).then(()=>{
let expectedActions = [{
type: FETCH_MOVIES,
payload: {
response: {
name: 'gemini man',
id: 23
}
}
}]
expect(store.getActions()).toEqual(expectedActions);
})
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment