ebac051dc0005d2a574548c714f113acb4783072
[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",
38 "type" => "Document",
39 "url" =>
40 "http://mastodon.example.org/system/media_attachments/files/000/000/001/original/8619f31c6edec470.png"
41 }
42 }
43
44 expected_object = %{
45 url:
46 "http://mastodon.example.org/system/media_attachments/files/000/000/001/original/8619f31c6edec470.png",
47 mimetype: "image/png",
48 oembed: false,
49 id: nil
50 }
51
52 assert expected_object == ObjectRepresenter.to_map(object)
53 end
54 end