debianize-mobilizon/test/mobilizon/service/activity_pub/utils_test.exs

47 lines
1.5 KiB
Elixir
Raw Normal View History

defmodule Mobilizon.Service.ActivityPub.UtilsTest do
2019-09-22 16:26:23 +02:00
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
use Mobilizon.DataCase
2019-09-22 16:26:23 +02:00
import Mobilizon.Factory
2019-09-22 16:26:23 +02:00
2019-09-22 18:29:13 +02:00
alias Mobilizon.Service.ActivityPub.{Converter, Utils}
2019-09-22 16:26:23 +02:00
alias MobilizonWeb.Endpoint
2019-09-22 16:26:23 +02:00
alias MobilizonWeb.Router.Helpers, as: Routes
setup_all do
HTTPoison.start()
end
describe "make" do
test "comment data from struct" do
comment = insert(:comment)
reply = insert(:comment, in_reply_to_comment: comment)
assert %{
"type" => "Note",
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
"content" => reply.text,
"actor" => reply.actor.url,
"uuid" => reply.uuid,
"id" => Routes.page_url(Endpoint, :comment, reply.uuid),
"inReplyTo" => comment.url,
"attributedTo" => reply.actor.url
2019-09-22 18:29:13 +02: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 = Utils.make_comment_data(reply.actor.url, to, reply.text, comment.url)
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