-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for async action and add mock data for tests
- Loading branch information
Michal Bartosik
committed
May 21, 2021
1 parent
3403369
commit 1e13ddc
Showing
16 changed files
with
14,382 additions
and
3,199 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import App from './App'; | ||
import * as api from './helpers/api'; | ||
import data from 'mocks/data'; | ||
|
||
jest.mock('./helpers/api.ts'); | ||
describe('App component', () => { | ||
it('renders countries list if request succeeds', async () => { | ||
const mockGetCountries = jest.spyOn(api, 'default'); | ||
mockGetCountries.mockImplementationOnce((): Promise<any> => { | ||
return Promise.resolve(data); | ||
}); | ||
|
||
render(<App />); | ||
|
||
const countries = await screen.findAllByTestId('country'); | ||
expect(mockGetCountries).toBeCalledTimes(1); | ||
expect(countries).toHaveLength(20); | ||
}); | ||
}); |
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
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
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
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
Oops, something went wrong.
1e13ddc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: