fix(export): emit date custom-field values as ISO-8601 for re-import
This commit is contained in:
parent
d51dcb1ac3
commit
5c5fd56749
2 changed files with 35 additions and 4 deletions
27
test/mv/membership/custom_field_value_formatter_test.exs
Normal file
27
test/mv/membership/custom_field_value_formatter_test.exs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue