-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#276 implement first tests to fe #283
Conversation
async () => { | ||
await axios.get.mockResolvedValue({ |
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.
Do you need async/await here?
I think we can import axios once and then mock it rather than importing it for every test
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.
Thank you for feedback. Values, returned by axios.get.mockResolvedValue, are different in those tests. So I can't mock it once
Deleted async/await
|
||
afterEach(cleanup); | ||
|
||
describe('CookieMod component unit tests', () => { |
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.
Could you add test cases that verify behavior? I mean hiding a modal when agree was clicked
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.
Thank you for feedback. Done
afterEach(cleanup); | ||
|
||
describe('CookieMod component unit tests', () => { | ||
test('renders agry button', () => { |
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.
Typo agree
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.
Thank you for feedback. Fixed))
expect(axios.get).toBeCalled(); | ||
expect(screen.getByText(/назад/i, { exact: false })).toBeInTheDocument(); | ||
expect(screen.getByRole('link')).toHaveAttribute('href', '/'); | ||
expect(screen.getByText(/3/i, { exact: false })).toBeInTheDocument(); |
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.
What does this test verify?
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.
Thank you for feedback. By strings:
85 - axios was called from page
86 - button 'назад' exists on the page
87 - button 'назад' binds with link '/' (to the main page)
88 - '3' - number of companies in axios mock request. We see '3' on the page, so the page works correctly
jest.mock('axios'); | ||
const axios = require('axios'); | ||
|
||
() => { |
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.
Do we need this wrapper?
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.
I tried 'axios.get = jest.fn().mockResolvedValue({ ...' but it doesn't work(( The only way I've found was this wrapper
Unit tests to CompanyCard, CookieMod, SearchResults, Search components. Just 'first touch'