Last active
August 18, 2020 10:16
-
-
Save mickaelw/5c96496469e5c76a01af7f09e8f1c6f4 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('Matches to snapshot', async () => { | |
const { asFragment } = render(<BookInformation | |
bookTitle={ 'title' } | |
dependencies={ dependencies }/> | |
) | |
await waitFor(() => { | |
expect(asFragment()).toMatchSnapshot() | |
}) | |
}) | |
it('Fetch book information', async () => { | |
render(<BookInformation bookTitle={ 'title' } dependencies={ dependencies }/>) | |
await waitFor(() => { | |
expect(dependencies.bookInformation).toHaveBeenCalledTimes(1) | |
expect(dependencies.bookInformation).toHaveBeenCalledWith('title') | |
}) | |
}) | |
it('Refresh book information', 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