2018-12-23 12:11:29 -08:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2017-03-30 07:08:49 -07: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 08:07:03 -07:00
|
|
|
],
|
|
|
|
"uuid" => 6
|
2017-03-30 07:08:49 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expected_object = %{
|
2017-03-30 08:07:03 -07:00
|
|
|
id: 6,
|
2017-03-30 07:08:49 -07:00
|
|
|
url: "someurl",
|
|
|
|
mimetype: "sometype",
|
2018-08-24 17:03:25 -07:00
|
|
|
oembed: false,
|
|
|
|
description: nil
|
2017-03-30 07:08:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
assert expected_object == ObjectRepresenter.to_map(object)
|
|
|
|
end
|
2018-02-11 08:21:06 -08:00
|
|
|
|
|
|
|
test "represents mastodon-style attachments" do
|
|
|
|
object = %Object{
|
|
|
|
id: nil,
|
|
|
|
data: %{
|
|
|
|
"mediaType" => "image/png",
|
2018-03-30 06:01:53 -07:00
|
|
|
"name" => "blabla",
|
|
|
|
"type" => "Document",
|
|
|
|
"url" =>
|
|
|
|
"http://mastodon.example.org/system/media_attachments/files/000/000/001/original/8619f31c6edec470.png"
|
2018-02-11 08:21:06 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expected_object = %{
|
2018-03-30 06:01:53 -07:00
|
|
|
url:
|
|
|
|
"http://mastodon.example.org/system/media_attachments/files/000/000/001/original/8619f31c6edec470.png",
|
2018-02-11 08:21:06 -08:00
|
|
|
mimetype: "image/png",
|
|
|
|
oembed: false,
|
2018-08-24 17:03:25 -07:00
|
|
|
id: nil,
|
|
|
|
description: "blabla"
|
2018-02-11 08:21:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
assert expected_object == ObjectRepresenter.to_map(object)
|
|
|
|
end
|
2017-03-30 07:08:49 -07:00
|
|
|
end
|