tuna42na / baby-namr

Baby Naming Application Frontend
0 stars 1 forks source link

Sample component unit tests #17

Closed trvslhlt closed 3 years ago

trvslhlt commented 3 years ago

Issue #15

I wanted to learn how to write unit tests for react components. In the process I refactored the Chart component. What the refactoring should accomplish is:

  1. The component is now loosely coupled with the NameListContext. The context fetches name history data and makes that available to child components. The components then contain all the logic for using that data to update the display. And, the details of the third-party chart api are encapsulated in Chart.
  2. Limits the scope of the try/catch that fetches names history.
  3. Makes the component more generic. It can be used for data besides popularity.