Skip to content

Instantly share code, notes, and snippets.

@mickaelw
Last active August 18, 2020 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mickaelw/479192a4da649110b4a6be2c5b9bad95 to your computer and use it in GitHub Desktop.
Save mickaelw/479192a4da649110b4a6be2c5b9bad95 to your computer and use it in GitHub Desktop.
describe('Integration | Component | Book information', () => {
let dependencies: Dependencies
beforeEach(() => {
dependencies = {
bookInformation: jest.fn().mockResolvedValue(null)
}
})
it('Vérification du snapshot', async () => {
const { asFragment } = render(<BookInformation bookTitle={ 'title' } dependencies={ dependencies }/>)
await waitFor(() => {
expect(asFragment()).toMatchSnapshot()
})
})
it('Récupération des informations du livre', async () => {
render(<BookInformation bookTitle={ 'title' } dependencies={ dependencies }/>)
await waitFor(() => {
expect(dependencies.bookInformation).toHaveBeenCalledTimes(1)
expect(dependencies.bookInformation).toHaveBeenCalledWith('title')
})
})
it('Rafraîchir les informations du livre', async () => {
const { getByTestId } = render(<BookInformation bookTitle={ 'title' } dependencies={ dependencies }/>)
fireEvent.click(getByTestId('refresh-button'))
await waitFor(() => {
expect(dependencies.bookInformation).toHaveBeenCalledTimes(2)
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment