Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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