2020-01-22 21:40:40 +00:00
|
|
|
defmodule Mobilizon.Federation.ActivityStream.Converter.ActorTest do
|
2019-05-22 12:12:11 +00:00
|
|
|
use Mobilizon.DataCase
|
2019-09-22 14:26:23 +00:00
|
|
|
|
2019-05-22 12:12:11 +00:00
|
|
|
alias Mobilizon.Actors.Actor
|
2020-01-22 01:14:42 +00:00
|
|
|
|
2020-01-22 21:40:40 +00:00
|
|
|
alias Mobilizon.Federation.ActivityStream.Converter.Actor, as: ActorConverter
|
2019-05-22 12:12:11 +00:00
|
|
|
|
|
|
|
describe "actor to AS" do
|
|
|
|
test "valid actor to as" do
|
|
|
|
data = ActorConverter.model_to_as(%Actor{type: :Person, preferred_username: "test_account"})
|
|
|
|
assert is_map(data)
|
2019-12-03 10:29:51 +00:00
|
|
|
assert data["type"] == :Person
|
|
|
|
assert data["preferredUsername"] == "test_account"
|
2019-05-22 12:12:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "AS to Actor" do
|
|
|
|
test "valid as data to model" do
|
2019-10-25 15:43:37 +00:00
|
|
|
{:ok, actor} =
|
2019-05-22 12:12:11 +00:00
|
|
|
ActorConverter.as_to_model_data(%{
|
2019-12-03 10:29:51 +00:00
|
|
|
"id" => "https://somedomain.tld/users/someone",
|
2019-05-22 12:12:11 +00:00
|
|
|
"type" => "Person",
|
2019-09-04 16:24:31 +00:00
|
|
|
"preferredUsername" => "test_account"
|
2019-05-22 12:12:11 +00:00
|
|
|
})
|
|
|
|
|
2019-12-03 10:29:51 +00:00
|
|
|
assert actor.type == "Person"
|
|
|
|
assert actor.preferred_username == "test_account"
|
2019-05-22 12:12:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|