Created
February 10, 2020 08:28
-
-
Save huxaiphaer/bf8e224def803a63addce8001ef63e34 to your computer and use it in GitHub Desktop.
This file contains 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 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