Update AuthorTransformer to check if the "data" attibute is available.

This commit is contained in:
2025-03-19 13:45:27 +02:00
parent d398cc1594
commit da0e5246c7
2 changed files with 32 additions and 5 deletions
@@ -29,5 +29,23 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.AuthorTransformerTest do
description: "Something"
} = author
end
test "a json doesn't contains author information \"data\" attribute" do
json_body = %{
"attributes" => %{"description" => "Something", "name" => "Author"},
"id" => "889a323e-d104-4b5d-b276-dad5a9b1da9d",
"links" => %{},
"meta" => %{},
"relationships" => %{},
"type" => "author"
}
assert {:ok, author} = AuthorTransformer.from_json(json_body)
assert %{
id: "889a323e-d104-4b5d-b276-dad5a9b1da9d",
name: "Author",
description: "Something"
} = author
end
end
end