-
Notifications
You must be signed in to change notification settings - Fork 95
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
minichallenge4 solved #85
base: master
Are you sure you want to change the base?
Conversation
oscarfiend
commented
Aug 12, 2021
"hooks": {} | ||
}, | ||
"jest": { | ||
"coveragePathIgnorePatterns": [ |
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 think you should remove the next files for this config:
"/src/providers",
"/src/providers",
"/src/config",
"/src/helpers/",
"/src/utils/",
"/src/index.js",
"/src/components/Fortune",
"/pages/NotFound",
"/components/App/"
They are part of the current app, so they should be included on the code coverage testing.
Please remove and update the code coverage report.
Any question or comment let me know.
Acceptance Criteria
Bonus Points
General comments
I think is because the tests are fetching to the real youtube api.
|
src/__tests__/videoDetails.test.js
Outdated
}); | ||
|
||
test('should containt a video description', () => { | ||
// const titleVideo = screen.findByText(/una librería para crear interfaces web/i); |
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.
remember to remove commented code
src/__tests__/videoList.test.js
Outdated
const list = screen.findAllByTestId(/list_videos/i); | ||
expect((await list).length).toBe(24) | ||
}); | ||
}); |
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.
This are good test cases, but remember to mock the api call.https://jestjs.io/docs/mock-functions
Good idea to separate the React context, one for Theme and another one for Video api logic, good work :D |
const menu = screen.getByTestId(/hamburguerMenu/i); | ||
expect(menu).toHaveAttribute('type', 'checkbox'); | ||
}); | ||
}); |
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.
Great test, I see that you are mocking the Api, good work!
|
||
test('Toggle button should be checkbox type', () => { | ||
const toggle = screen.getByRole('checkbox'); | ||
expect(toggle).toHaveAttribute('type', 'checkbox'); |
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.
Since you are doing the query getByRole('checkbox')
, there is explicitly that the element is a checkbox, so you could do the expect using toBeInTheDocument()
, makes sense?
const title = screen.getByText(/Youtube challenge/i); | ||
expect(title).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.
is this Home component actually fetching the API?
const videoCreation = screen.queryByText(video.publishedAt); | ||
expect(videoCreation).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.
Great work :D
test('should containt a video iframe', () => { | ||
waitFor(() => expect(screen.findByRole(/iframe/i)).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.
Good test,
You can refactor this kind of expects:
waitFor(() => expect(screen.findByText(/Qué es React/i)).toBeInTheDocument());
to only
expect(await screen.findByText(/Qué es React/i)).toBeInTheDocument()
because findBy
is a combination of getBy and waitFor: https://testing-library.com/docs/dom-testing-library/api-async/#findby-queries
baseURL: 'https://content-youtube.googleapis.com/youtube/v3/', | ||
}); | ||
|
||
export default axiosClient; |
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.
Good use of axios instance.
Go one more step ahead and try to put the baseURL value as Env variable, in order to get this more easy to change on the time.
UPDATE_QUERY_VIDEO, | ||
} from '../../utils/constants'; | ||
|
||
export default (state = {}, { type, payload }) => { |
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.
Is a good idea to have the initial state with the default properties values