Skip to content

Conversation

@fernandaMadin
Copy link
Owner

No description provided.

Copy link

@wdonet wdonet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I could not make it work at Codesandbox but did it on my local 🎉

All functionalities work fine except that when selecting a new video from the list and you're viewing one already. That list of related videos is not updated with the new clicks.

I left a few comments. You have a great opportunity to add better unit test thus increase your code coverage.

Good job though. You made it 👏🏽 - please do the adjustments as you consider and merge later to continue to the next challenge.

Please ask any question.

------------------------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
------------------------------|----------|----------|----------|----------|-------------------|
All files | 61.61 | 50 | 50 | 62.16 | |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good enough for now, thanks for adding the file!

return (
<BrowserRouter>
<AuthProvider>
<NavBar word={word} setWord={setWord} />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems word is used only inside NavBar component, so maybe it is more useful inside the component than here.

You can always send the setVideos function to NavBar as you did with setword for saving the videos into this context

});

it('renders all children', () => {
const layout = screen.getByTestId('layout');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout component renders a main html tag. This is reachable by role : main. Thus the data-testid is not necessary.

Comment on lines +20 to +22
const handleChange = (event) => {
setSearchWord(event.target.value);
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using destructuring could be simpler:

Suggested change
const handleChange = (event) => {
setSearchWord(event.target.value);
};
const handleChange = ({ target: { value } }) => setSearchWord(value);

it('renders SideMenu and its elements', () => {
const sideMenu = screen.getByTestId('sideMenu');
expect(sideMenu.children.length).toEqual(1);
expect(sideMenu.children[0].children.length).toEqual(2);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can enrich your tests by looking for specific components like buttons, input texts or content that can be changed based on the arguments passed to the component.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing only for the number of children inside the main container at each component could be the cause of a low coverage.


beforeEach(() => {
render(
<BrowserRouter>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure you need to use BrowserRouter here

Comment on lines +8 to +16
{videos.map((video) =>
video.id.videoId ? (
<Col key={video.id.videoId}>
<VideoCard key={video.id.videoId} video={video} />
</Col>
) : (
''
)
)}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could improve doing:

  • using the provided index by map fn at the key prop for the Col component this case
  • The second key prop is not necessary, it is used at Col only.
Suggested change
{videos.map((video) =>
video.id.videoId ? (
<Col key={video.id.videoId}>
<VideoCard key={video.id.videoId} video={video} />
</Col>
) : (
''
)
)}
{videos.map((video, index) =>
video.id.videoId ? (
<Col key={index}>
<VideoCard video={video} />
</Col>
) : (
''
)
)}

@@ -0,0 +1,17 @@
const key = 'AIzaSyCbnwRIBvWCoQGaLIOFUx4rhLHg-Sb1a8s';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱
Do not save your api key at public repositories, it is better if you handle it with environment variables. Check dotenv for example.

export async function fetchVideos(keyWord) {
const apiBaseUrl = `https://content-youtube.googleapis.com/youtube/v3/search?part=id&part=snippet&maxResults=25&q=${keyWord}&key=${key}`;

return fetch(apiBaseUrl)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if this fn is a custom hook instead ? Do you see a better/cleaner usage for this functionality at the other components using it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants