-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29edbb6
commit 72e8660
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |