Skip to content

minichallenge4 solved#85

Open
oscarfiend wants to merge 3 commits into
cvillanueva84:masterfrom
oscarfiend:Minichallenge4-solved
Open

minichallenge4 solved#85
oscarfiend wants to merge 3 commits into
cvillanueva84:masterfrom
oscarfiend:Minichallenge4-solved

Conversation

@oscarfiend

Copy link
Copy Markdown

Screenshot_304

Comment thread package.json
"hooks": {}
},
"jest": {
"coveragePathIgnorePatterns": [

@ghost ghost Aug 13, 2021

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 think you should remove the next files for this config:

"/src/providers",
"/src/providers",
"/src/config",
"/src/helpers/",
"/src/utils/",
"/src/index.js",
"/src/components/Fortune",
"/pages/NotFound",
"/components/App/"

They are part of the current app, so they should be included on the code coverage testing.

Please remove and update the code coverage report.

Any question or comment let me know.

@ghost

ghost commented Aug 13, 2021

Copy link
Copy Markdown

Acceptance Criteria

  • The search term is stored and retrieved from the Global Context correctly.
  • The appearance theme is stored on the Global Context and applied correctly to the App UI.
  • useReducer hook is implemented correctly to manage the Global State.

Bonus Points

  • Testing coverage is above 70%. (Please include a screenshot of the code coverage report in your PR description).

General comments

  • Make sure that you are adding the package-lock.json on git.
  • When I run the tests on my local machine, I have:
 TestingLibraryElementError: Unable to find an element by: [data-testid="/list_videos/i"]

    <body>
      <div>
        <h2>
          Error fetching data, try later
        </h2>
      </div>
    </body>

    <body>
      <div>
        <h2>
          Error fetching data, try later
        </h2>
      </div>
    </body>Error: Unable to find an element by: [data-testid="/list_videos/i"]

    <body>
      <div>
        <h2>
          Error fetching data, try later
        </h2>
      </div>
    </body>
Test Suites: 2 failed, 4 passed, 6 total
Tests:       3 failed, 21 passed, 24 total
Snapshots:   0 total
Time:        7.877s

I think is because the tests are fetching to the real youtube api.

Comment thread src/__tests__/videoDetails.test.js Outdated
});

test('should containt a video description', () => {
// const titleVideo = screen.findByText(/una librería para crear interfaces web/i);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

remember to remove commented code

Comment thread src/__tests__/videoList.test.js Outdated
const list = screen.findAllByTestId(/list_videos/i);
expect((await list).length).toBe(24)
});
}); No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This are good test cases, but remember to mock the api call.https://jestjs.io/docs/mock-functions

@ghost

ghost commented Aug 13, 2021

Copy link
Copy Markdown

Good idea to separate the React context, one for Theme and another one for Video api logic, good work :D

const menu = screen.getByTestId(/hamburguerMenu/i);
expect(menu).toHaveAttribute('type', 'checkbox');
});
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great test, I see that you are mocking the Api, good work!


test('Toggle button should be checkbox type', () => {
const toggle = screen.getByRole('checkbox');
expect(toggle).toHaveAttribute('type', 'checkbox');

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 are doing the query getByRole('checkbox'), there is explicitly that the element is a checkbox, so you could do the expect using toBeInTheDocument(), makes sense?

const title = screen.getByText(/Youtube challenge/i);
expect(title).toBeInTheDocument();
});
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is this Home component actually fetching the API?

const videoCreation = screen.queryByText(video.publishedAt);
expect(videoCreation).toBeInTheDocument();
});
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great work :D

test('should containt a video iframe', () => {
waitFor(() => expect(screen.findByRole(/iframe/i)).toBeInTheDocument());
});
});

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 test,

You can refactor this kind of expects:

waitFor(() => expect(screen.findByText(/Qué es React/i)).toBeInTheDocument());

to only

expect(await screen.findByText(/Qué es React/i)).toBeInTheDocument()

because findBy is a combination of getBy and waitFor: https://testing-library.com/docs/dom-testing-library/api-async/#findby-queries

Comment thread src/config/axios.js
baseURL: 'https://content-youtube.googleapis.com/youtube/v3/',
});

export default axiosClient;

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 use of axios instance.

Go one more step ahead and try to put the baseURL value as Env variable, in order to get this more easy to change on the time.

UPDATE_QUERY_VIDEO,
} from '../../utils/constants';

export default (state = {}, { type, payload }) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is a good idea to have the initial state with the default properties values

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.

1 participant