27 lines
934 B
Elixir
27 lines
934 B
Elixir
defmodule Mv.Membership.CustomFieldValueFormatterTest do
|
|
use ExUnit.Case, async: true
|
|
|
|
alias Mv.Membership.CustomFieldValueFormatter
|
|
|
|
describe "format_custom_field_value/2 for :date" do
|
|
test "formats an Ash.Union date value as ISO-8601" do
|
|
union = %Ash.Union{value: ~D[2024-03-15], type: :date}
|
|
|
|
assert CustomFieldValueFormatter.format_custom_field_value(union, %{value_type: :date}) ==
|
|
"2024-03-15"
|
|
end
|
|
|
|
test "formats a direct Date value as ISO-8601" do
|
|
assert CustomFieldValueFormatter.format_custom_field_value(~D[2024-03-15], %{
|
|
value_type: :date
|
|
}) == "2024-03-15"
|
|
end
|
|
|
|
test "formats an already-stored ISO-8601 string date as ISO-8601" do
|
|
union = %Ash.Union{value: "2024-03-15", type: :date}
|
|
|
|
assert CustomFieldValueFormatter.format_custom_field_value(union, %{value_type: :date}) ==
|
|
"2024-03-15"
|
|
end
|
|
end
|
|
end
|