Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
zorn committed Jan 2, 2025
1 parent 77579fc commit 7f493db
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion test/flick/ranked_voting_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,28 @@ defmodule Flick.RankedVotingTest do
end

describe "ballot_status/1" do
# TODO
test "returns `:draft` for a non-published ballot" do
ballot = ballot_fixture()
assert :draft = RankedVoting.ballot_status(ballot)
end

test "returns `:published` for a published ballot" do
ballot = published_ballot_fixture()
assert :published = RankedVoting.ballot_status(ballot)
end

test "returns `:closed` for a closed ballot" do
ballot = closed_ballot_fixture()
assert :closed = RankedVoting.ballot_status(ballot)
end

test "raises when encountering an unknown status" do
ballot = %Ballot{published_at: nil, closed_at: DateTime.utc_now()}

assert_raise RuntimeError, "invalid state observed", fn ->
RankedVoting.ballot_status(ballot)
end
end
end

describe "list_ballots/1" do
Expand Down

0 comments on commit 7f493db

Please sign in to comment.