Skip to content
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

Mini-Challenge 5: Routing #97

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

LuisRamirezHdz
Copy link

1
2

@LuisRamirezHdz LuisRamirezHdz changed the title Routing Mini-Challenge 5: Routing Aug 24, 2021
Copy link

@dianaatwizeline dianaatwizeline left a comment

Choose a reason for hiding this comment

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

Good job on this PR.

return (
<>
<h1>You haven't added any video to your favorites yet</h1>
</>

Choose a reason for hiding this comment

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

I expected to see this message when going to the favorite's route without adding any favorites but instead I get an empty screen. I think you will need to use your storage and count the items there

);
var path = '';
if (route === '/') {
path = 'video';

Choose a reason for hiding this comment

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

I recommend moving both video and favorites to a constant in utils/constants

fireEvent.click(screen.getByTestId('Logmenu'));
fireEvent.click(screen.getByText('Cancel'));
const cancelButton = screen.queryAllByText('Cancel');
expect(cancelButton).toHaveLength(0);

Choose a reason for hiding this comment

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

a way we can improve our tests is to test to what we should be seeing in the screen instead of what is happening "behind the scenes" so instead of using queryAllBy since we only expect 0 or 1 as results we can use queryBy and then we can use not.toBeIntheDocument instead to verify that the user will not be able to see the button

useEffect(() => {
if (FavoritesList?.items) {
//Add or Remove?
let filterFavorites = FavoritesList.items.filter((e) => e.id.videoId === id);

Choose a reason for hiding this comment

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

most of the times you're looking for only one element in an array it's more efficient to use .find instead. That returns a boolean so you wouldn't need the .length in the condition below

}
}, [FavoritesList, id]);
function handleClick() {
if (buttonAction === 'Add') {

Choose a reason for hiding this comment

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

since you're using 'Add' and 'Remove' in many places in this file. I recommend you use a constant for them to minimize the probability on errors on typos.

const Actions = {
   ADD = 'Add',
   REMOVE = 'Remove'
}

or

const ACTION_ADD = 'Add';
const ACTION_REMOVE = 'Remove';

);
}

export default VideoDetailsView;

Choose a reason for hiding this comment

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

You have some code that could be reused in FavoriteVideoDetailsView and VideoDetailsView. I recommend instead of two total components you create an extra one that has everything that is shared between these two components and that everything that is different is sent down as props from the two existing components.

Your new component should be the one that is roughly 100 lines long and the existing two should be way shorter as they will only do the things that are particular for them and everything shared is in the new component.

This might benefit from a file renaming as well:

VideoDetailsView -> MainVideoDetailsView
FavoriteVideoDetailsView -> stays the same
new component -> VideoDetailsView

@LuisRamirezHdz
Copy link
Author

@dianaatwizeline ,
I appreciate the time that you gave me in each feedback throughout this Bootcamp. I always tried to apply all your suggestions. Can you see the final result in the new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants