logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

object_representer_test.exs (1489B)


      1 # Pleroma: A lightweight social networking server
      2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
      3 # SPDX-License-Identifier: AGPL-3.0-only
      4 
      5 defmodule Pleroma.Web.TwitterAPI.Representers.ObjectReprenterTest do
      6   use Pleroma.DataCase
      7 
      8   alias Pleroma.Object
      9   alias Pleroma.Web.TwitterAPI.Representers.ObjectRepresenter
     10 
     11   test "represent an image attachment" do
     12     object = %Object{
     13       id: 5,
     14       data: %{
     15         "type" => "Image",
     16         "url" => [
     17           %{
     18             "mediaType" => "sometype",
     19             "href" => "someurl"
     20           }
     21         ],
     22         "uuid" => 6
     23       }
     24     }
     25 
     26     expected_object = %{
     27       id: 6,
     28       url: "someurl",
     29       mimetype: "sometype",
     30       oembed: false,
     31       description: nil
     32     }
     33 
     34     assert expected_object == ObjectRepresenter.to_map(object)
     35   end
     36 
     37   test "represents mastodon-style attachments" do
     38     object = %Object{
     39       id: nil,
     40       data: %{
     41         "mediaType" => "image/png",
     42         "name" => "blabla",
     43         "type" => "Document",
     44         "url" =>
     45           "http://mastodon.example.org/system/media_attachments/files/000/000/001/original/8619f31c6edec470.png"
     46       }
     47     }
     48 
     49     expected_object = %{
     50       url:
     51         "http://mastodon.example.org/system/media_attachments/files/000/000/001/original/8619f31c6edec470.png",
     52       mimetype: "image/png",
     53       oembed: false,
     54       id: nil,
     55       description: "blabla"
     56     }
     57 
     58     assert expected_object == ObjectRepresenter.to_map(object)
     59   end
     60 end