Unit Testing the Survey Results State

Let's learn how to perform unit testing on a LiveView component.

We’ll begin with some unit tests that cover the SurveyResultsLive component’s ability to manage survey results data in state. First up is the assign_products_with_average_ratings/2 reducer function, which needs to handle both an empty survey results dataset and one with existing product ratings. First, we’ll make sure the reducer creates the correct socket state when no product ratings exist.

Get hands-on with 1200+ tech skills courses.