1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-23 08:22:50 +00:00
mobilizon/test/federation/activity_pub/utils_test.exs

57 lines
1.8 KiB
Elixir
Raw Normal View History

2020-01-22 01:14:42 +00:00
defmodule Mobilizon.Federation.ActivityPub.UtilsTest do
2019-09-22 14:26:23 +00:00
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
use Mobilizon.DataCase
2019-09-22 14:26:23 +00:00
import Mobilizon.Factory
2019-09-22 14:26:23 +00:00
alias Mobilizon.Federation.ActivityStream.Converter
2019-09-22 14:26:23 +00:00
2020-01-26 20:36:50 +00:00
alias Mobilizon.Web.Endpoint
alias Mobilizon.Web.Router.Helpers, as: Routes
setup_all do
HTTPoison.start()
end
describe "make" do
test "comment data from struct" do
comment = insert(:comment)
tag = insert(:tag, title: "MyTag")
reply = insert(:comment, in_reply_to_comment: comment, tags: [tag])
assert %{
"type" => "Note",
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
"cc" => [],
"tag" => [
%{
"href" => "http://mobilizon.test/tags/#{tag.slug}",
"name" => "#MyTag",
"type" => "Hashtag"
}
],
"content" => "My Comment",
"actor" => reply.actor.url,
"uuid" => reply.uuid,
"id" => Routes.page_url(Endpoint, :comment, reply.uuid),
"inReplyTo" => comment.url,
"attributedTo" => reply.actor.url,
"mediaType" => "text/html"
2019-09-22 16:29:13 +00:00
} == Converter.Comment.model_to_as(reply)
end
test "comment data from map" do
comment = insert(:comment)
reply = insert(:comment, in_reply_to_comment: comment)
to = ["https://www.w3.org/ns/activitystreams#Public"]
comment_data = Converter.Comment.model_to_as(reply)
assert comment_data["type"] == "Note"
assert comment_data["to"] == to
assert comment_data["content"] == reply.text
assert comment_data["actor"] == reply.actor.url
assert comment_data["inReplyTo"] == comment.url
end
end
end