Skip to content

Commit

Permalink
Merge pull request #66 from antoinereyt/fix-tests
Browse files Browse the repository at this point in the history
Fixes tests
  • Loading branch information
jfornoff authored Jul 7, 2021
2 parents 328a39f + 1c4d79e commit 3d91857
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions lib/vex/blank.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ defimpl Vex.Blank, for: Map do
def blank?(map), do: map_size(map) == 0
end

defimpl Vex.Blank, for: [Date, DateTime, NaiveDateTime] do
def blank?(nil), do: true
defimpl Vex.Blank, for: [Date, DateTime, NaiveDateTime, Time] do
def blank?(_), do: false
end

Expand Down
8 changes: 3 additions & 5 deletions test/validations/presence_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ defmodule PresenceTest do
assert Vex.valid?([date: Date.utc_today()], date: [presence: true])
assert Vex.valid?([date: NaiveDateTime.utc_now()], date: [presence: true])
assert Vex.valid?([date: DateTime.utc_now()], date: [presence: true])
refute Vex.valid?([date: nil], date: [presence: true])
refute Vex.valid?([date: nil], date: [presence: true])
assert Vex.valid?([date: Time.utc_now()], date: [presence: true])
refute Vex.valid?([date: nil], date: [presence: true])
end

Expand All @@ -40,9 +39,8 @@ defmodule PresenceTest do
assert Vex.valid?(%{"date" => Date.utc_today()}, %{"date" => [presence: true]})
assert Vex.valid?(%{"date" => DateTime.utc_now()}, %{"date" => [presence: true]})
assert Vex.valid?(%{"date" => NaiveDateTime.utc_now()}, %{"date" => [presence: true]})
refute Vex.valid?([date: nil], %{"date" => [presence: true]})
refute Vex.valid?([date: nil], %{"date" => [presence: true]})
refute Vex.valid?([date: nil], %{"date" => [presence: true]})
assert Vex.valid?(%{"date" => Time.utc_now()}, %{"date" => [presence: true]})
refute Vex.valid?(%{"date" => nil}, %{"date" => [presence: true]})
end

test "keyword list, included presence validation" do
Expand Down

0 comments on commit 3d91857

Please sign in to comment.