-
Notifications
You must be signed in to change notification settings - Fork 52
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
Video Details View - Mini Challenge 3 #47
base: master
Are you sure you want to change the base?
Conversation
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 made a few suggestions, I would love to see more styled-components even though you use Material UI. Let me know if you need help with this.
Also, I see a high coverage but not real unit tests. That's not ideal bc they are not helping you out to understand the code.
There are various files deleted, just make sure you are not removing main components for other functionalities.
I saw it working in a stable manner but you should think in support your code with good unit tests.
------------------------------|----------|----------|----------|----------|-------------------| | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | | ||
------------------------------|----------|----------|----------|----------|-------------------| | ||
All files | 84.21 | 50 | 88.89 | 82.35 | | |
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 coverage so far
|
||
describe('App', () => { | ||
it('renders App component', () => { | ||
render(<App />); |
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.
Hmm 🤔 , this test is expecting nothing, this would increase your coverage but not really testing anything else than it is rendering with no errors
|
||
describe('Navbar', () => { | ||
it('renders Navbar component', () => { | ||
render(<Navbar />); |
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.
same 😢
|
||
console.log(videoInfo); | ||
|
||
const classes = useStyles(); |
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.
you are not passing a theme object, so I think that's the reason you are missing more than several styles at your components. Do not want to try styled-components instead?
|
||
const classes = useStyles(); | ||
const { title, channelTitle, thumbnails } = videoInfo.snippet; | ||
const { videoId } = videoInfo.id; |
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.
const { videoId } = videoInfo.id; | |
const { id: videoId } = videoInfo; // looks better in my opinion |
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.
even better if you integrate it with the previous line
} | ||
} | ||
|
||
export default withStyles(useStyles)(CardVideo); |
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.
it is a good practice to leave an empty line at EOF
|
||
this.classes = props.classes; | ||
this.videoInfo = props.videoInfo; | ||
this.videoId = (typeof this.videoInfo.id === 'object') ? this.videoInfo.id.videoId : this.videoInfo.id; |
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 comparison is not secure due to the variants of results of typeof
. Instead you could try:
this.videoId = (typeof this.videoInfo.id === 'object') ? this.videoInfo.id.videoId : this.videoInfo.id; | |
const { id = {} } = props.videInfo; // provide a default value - could be numeric too | |
this.videoId = id.videoId || id; // if not an object with that videoId property, it takes the value provided for id or the default in your code |
const response = await axios.get( | ||
'https://www.googleapis.com/youtube/v3/search', { | ||
params: { | ||
part: 'snippet', | ||
q: search, | ||
maxResults: 20, | ||
type: 'video', | ||
key: process.env.REACT_APP_YOUTUBE_API_KEY, | ||
} | ||
} | ||
) |
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.
Don't you think this could be refactored into a single fn that then is called at the two fetch.. functions?
Also, the code is not error handling for HTTP errors nor for wrong expected data
<Container maxWidth={false}> | ||
<Grid container justify="center" spacing={3}> | ||
{videos.map((video) => { | ||
let videoId = (typeof video.id === 'object') ? video.id.videoId : video.id; |
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.
if you're executing the same validation every time, this could be extracted to an external utility
import { Link, useHistory } from 'react-router-dom'; | ||
|
||
export default function Navbar(props){ | ||
const classes = useStyles(); |
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.
you could destructure the properties and use them directly at the JSX code
const classes = useStyles(); | |
const { root, menuButton, navbarTitle, ... etc } = useStyles(); |
No description provided.