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.

👌🏽 well done, you made it, I just added a few comments

btw, I noticed the theme toggle and user icon disappear on mobile or narrow views
image

coverage.txt Outdated
----------------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------------------|----------|----------|----------|----------|-------------------|
All files | 92.59 | 100 | 77.78 | 92.59 | |
Copy link

Choose a reason for hiding this comment

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

🚀 Awesome! - thanks for adding this

});

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.

Since the Layout has a styled component rendering a <main> HTML element, you should use getByRole('main') instead and leave test-id attributes for other elements difficult to reach


function Layout({ children }) {
return (
<Styled.Container className="container" data-testid="layout">
Copy link

Choose a reason for hiding this comment

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

Use data-test-id for more complex components that are harder to reach. The Styled.Container would be rendered as a main HTML and role - check

render(<NavBar />);
});

it('renders NavBar and its elements', () => {
Copy link

Choose a reason for hiding this comment

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

👌🏽 nice, it would be even better if you test user interaction for the navbar to open/close

@@ -0,0 +1,30 @@
import React from 'react';
import Styled from './styled';
Copy link

Choose a reason for hiding this comment

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

Use destructuring to clean your JSX code

Suggested change
import Styled from './styled';
import { CloseBtn, CloseIcon, ContainerMenu, Links, LinkText, SideMenu } from './styled';

});

it('renders SideMenu and its elements', () => {
const sideMenu = screen.getByTestId('sideMenu');
Copy link

Choose a reason for hiding this comment

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

Same as other tests, look for the internal elements and their details. Make your tests meaningful for the readers. Your tests should explain the usage of your production code

it('renders NavBar and its elements', () => {
const navBar = screen.getByTestId('navBar');
expect(navBar.children.length).toEqual(1);
const navContent = screen.getByTestId('navContent');
Copy link

Choose a reason for hiding this comment

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

Same as above, leave the usage of data-test-id as the last resource. Instead, you could use getByRole() to assert you have those 4 elements at specific:

  • A menu icon (maybe with a data-test-id - depending on the final render of a Dehaze Material UI component)
  • A side menu
  • An input, and
  • A checkbox

Comment on lines +16 to +17
expect(screen.getByText(items[1].snippet.title)).toBeTruthy();
expect(screen.getByText(items[1].snippet.description)).toBeTruthy();
Copy link

Choose a reason for hiding this comment

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

I agreed with the usage of data-test-id here but the expectation statements could be more descriptive using extra vars with the correct names like:

Suggested change
expect(screen.getByText(items[1].snippet.title)).toBeTruthy();
expect(screen.getByText(items[1].snippet.description)).toBeTruthy();
const videoData = items[1].snippet;
expect(screen.getByText(videoData.title)).toBeTruthy();
expect(screen.getByText(videoData.description)).toBeTruthy();

Comment on lines +16 to +17
const row = screen.getByTestId('row');
expect(row.children.length).toEqual(24);
Copy link

Choose a reason for hiding this comment

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

how about expecting the 24 elements are actually VideoCards? and that there's only one per Styled.Col

<Link to="/login">let me in →</Link>
)}
<section>
<div>
Copy link

Choose a reason for hiding this comment

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

I do not see the need for a div here since you are wrapping everything with a section

Fernanda Ramos and others added 2 commits March 5, 2021 22:35
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