Skip to content

Mini-Challenge 5: Routing#97

Open
LuisRamirezHdz wants to merge 19 commits into
cvillanueva84:masterfrom
LuisRamirezHdz:Routing
Open

Mini-Challenge 5: Routing#97
LuisRamirezHdz wants to merge 19 commits into
cvillanueva84:masterfrom
LuisRamirezHdz:Routing

Conversation

@LuisRamirezHdz

Copy link
Copy Markdown

1
2

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

@dianaatwizeline dianaatwizeline left a comment

Copy link
Copy Markdown

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>
</>

Copy link
Copy Markdown

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';

Copy link
Copy Markdown

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);

Copy link
Copy Markdown

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);

Copy link
Copy Markdown

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') {

Copy link
Copy Markdown

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;

Copy link
Copy Markdown

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
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

2 participants