Update AuthorTransformer to check if the "data" attibute is available.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user