Twitter Representers: Handle Mastodon attachments.
[akkoma] / test / web / twitter_api / representers / object_representer_test.exs
1 defmodule Pleroma.Web.TwitterAPI.Representers.ObjectReprenterTest do
2 use Pleroma.DataCase
3
4 alias Pleroma.Object
5 alias Pleroma.Web.TwitterAPI.Representers.ObjectRepresenter
6
7 test "represent an image attachment" do
8 object = %Object{
9 id: 5,
10 data: %{
11 "type" => "Image",
12 "url" => [
13 %{
14 "mediaType" => "sometype",
15 "href" => "someurl"
16 }
17 ],
18 "uuid" => 6
19 }
20 }
21
22 expected_object = %{
23 id: 6,
24 url: "someurl",
25 mimetype: "sometype",
26 oembed: false
27 }
28
29 assert expected_object == ObjectRepresenter.to_map(object)
30 end
31
32 test "represents mastodon-style attachments" do
33 object = %Object{
34 id: nil,
35 data: %{
36 "mediaType" => "image/png",
37 "name" => "blabla", "type" => "Document",
38 "url" => "http://mastodon.example.org/system/media_attachments/files/000/000/001/original/8619f31c6edec470.png"
39 }
40 }
41
42 expected_object = %{
43 url: "http://mastodon.example.org/system/media_attachments/files/000/000/001/original/8619f31c6edec470.png",
44 mimetype: "image/png",
45 oembed: false,
46 id: nil
47 }
48
49 assert expected_object == ObjectRepresenter.to_map(object)
50 end
51 end