Last active
April 3, 2020 17:21
-
-
Save RichardBray/014c1cf443b0f241581127e2e3379463 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 * as Store from "./AppContext"; | |
// ... | |
describe('App', () => { | |
// ... | |
describe('Question', () => { | |
// - context spy | |
const contextValues = { chosenAnswers: [], setChosenAnswers: () => {} }; | |
jest.spyOn(Store, 'useAppContext').mockImplementation(() => contextValues); | |
const getButton = question => question.find('Button'); | |
const wrapperProps = index => ({ index, result: data.results[0] }); | |
const wrapper = props => mount(<Question {...props} />); | |
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