Last active
August 18, 2020 10:19
-
-
Save mickaelw/479192a4da649110b4a6be2c5b9bad95 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
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