2017-03-30 08:08:49 -06:00
|
|
|
defmodule Pleroma.Web.TwitterAPI.Representers.ObjectReprenterTest do
|
|
|
|
use Pleroma.DataCase
|
|
|
|
|
|
|
|
alias Pleroma.Object
|
|
|
|
alias Pleroma.Web.TwitterAPI.Representers.ObjectRepresenter
|
|
|
|
|
|
|
|
test "represent an image attachment" do
|
|
|
|
object = %Object{
|
|
|
|
id: 5,
|
|
|
|
data: %{
|
|
|
|
"type" => "Image",
|
|
|
|
"url" => [
|
|
|
|
%{
|
|
|
|
"mediaType" => "sometype",
|
|
|
|
"href" => "someurl"
|
|
|
|
}
|
2017-03-30 09:07:03 -06:00
|
|
|
],
|
|
|
|
"uuid" => 6
|
2017-03-30 08:08:49 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expected_object = %{
|
2017-03-30 09:07:03 -06:00
|
|
|
id: 6,
|
2017-03-30 08:08:49 -06:00
|
|
|
url: "someurl",
|
|
|
|
mimetype: "sometype",
|
|
|
|
oembed: false
|
|
|
|
}
|
|
|
|
|
|
|
|
assert expected_object == ObjectRepresenter.to_map(object)
|
|
|
|
end
|
2018-02-11 09:21:06 -07:00
|
|
|
|
|
|
|
test "represents mastodon-style attachments" do
|
|
|
|
object = %Object{
|
|
|
|
id: nil,
|
|
|
|
data: %{
|
|
|
|
"mediaType" => "image/png",
|
|
|
|
"name" => "blabla", "type" => "Document",
|
|
|
|
"url" => "http://mastodon.example.org/system/media_attachments/files/000/000/001/original/8619f31c6edec470.png"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expected_object = %{
|
|
|
|
url: "http://mastodon.example.org/system/media_attachments/files/000/000/001/original/8619f31c6edec470.png",
|
|
|
|
mimetype: "image/png",
|
|
|
|
oembed: false,
|
|
|
|
id: nil
|
|
|
|
}
|
|
|
|
|
|
|
|
assert expected_object == ObjectRepresenter.to_map(object)
|
|
|
|
end
|
2017-03-30 08:08:49 -06:00
|
|
|
end
|