1 defmodule Pleroma.Web.ObjectValidators.Types.RecipientsTest do
2 alias Pleroma.EctoType.ActivityPub.ObjectValidators.Recipients
5 test "it asserts that all elements of the list are object ids" do
6 list = ["https://lain.com/users/lain", "invalid"]
8 assert :error == Recipients.cast(list)
11 test "it works with a list" do
12 list = ["https://lain.com/users/lain"]
13 assert {:ok, list} == Recipients.cast(list)
16 test "it works with a list with whole objects" do
17 list = ["https://lain.com/users/lain", %{"id" => "https://gensokyo.2hu/users/raymoo"}]
18 resulting_list = ["https://gensokyo.2hu/users/raymoo", "https://lain.com/users/lain"]
19 assert {:ok, resulting_list} == Recipients.cast(list)
22 test "it turns a single string into a list" do
23 recipient = "https://lain.com/users/lain"
25 assert {:ok, [recipient]} == Recipients.cast(recipient)