Created
April 3, 2020 17:35
-
-
Save RichardBray/ffd2c4bc3ee6021976fcd467f696b681 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 { Provider } from "react-redux"; | |
import configureStore from "redux-mock-store"; | |
// ... | |
describe('App', () => { | |
// ... | |
describe('Question', () => { | |
// - setup redux store | |
const mockReduxStore = configureStore(); | |
const initialReduxState = { chosenAnswers: [], setChosenAnswers: () => {} }; | |
const reduxStore = mockReduxStore(initialReduxState); | |
const getButton = question => question.find('Button'); | |
const wrapperProps = index => ({ index, result: data.results[0] }); | |
const wrapper = props => mount(<Provider store={reduxStore}><Question {...props} /></Provider>); | |
test('Should have only one Next button for the first question', () => { | |
// - when | |
const firstQuestion = wrapper(wrapperProps(0)); | |
// - then | |
expect(getButton(firstQuestion).text()).toEqual('next'); | |
expect(getButton(firstQuestion).length).toEqual(1); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment