Skip to content

Commit

Permalink
test: add tests to person
Browse files Browse the repository at this point in the history
  • Loading branch information
panoramix360 committed Sep 5, 2023
1 parent 29edbb6 commit 72e8660
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/app/person_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
defmodule App.PersonTest do
use ExUnit.Case
alias App.Person

@doc """
Test for `get_person_id/1`
"""
describe "get_person_id/1" do
test "returns id when person is present in assigns" do
assigns = %{person: %{id: 1}}
assert Person.get_person_id(assigns) == 1
end

test "returns 0 when person is not present in assigns" do
assigns = %{}
assert Person.get_person_id(assigns) == 0
end

test "returns 0 when id is not present in person" do
assigns = %{person: %{}}
assert Person.get_person_id(assigns) == 0
end

test "returns 0 when id is nil in person" do
assigns = %{person: %{id: nil}}
assert Person.get_person_id(assigns) == 0
end
end
end

0 comments on commit 72e8660

Please sign in to comment.