Next, we can move on to actually writing our tests. We'll want to test two things, specifically:
- When we have multiple polls, we want to return them in the order of most-recently created to least-recently created.
- When we are including pagination params (page and per_page), we should get the correct results (also respecting ordering).
We'll start with a test to cover the first scenario, since that should be pretty simple to write:
test "list_most_recent_polls/2 returns polls ordered by the most recent first", %{user: user} do poll = poll_fixture(%{user_id: user.id}) poll2 = poll_fixture(%{user_id: user.id}) poll3 = poll_fixture(%{user_id: user.id}) assert Votes.list_most_recent_polls() == [poll3, poll2, poll]end
What ...