Pipeline Ingestion: Note
[akkoma] / test / pleroma / ecto_type / activity_pub / object_validators / recipients_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.RecipientsTest do
6 alias Pleroma.EctoType.ActivityPub.ObjectValidators.Recipients
7 use Pleroma.DataCase, async: true
8
9 test "it only keeps elements that are valid object ids" do
10 list = ["https://lain.com/users/lain", "invalid"]
11
12 assert {:ok, ["https://lain.com/users/lain"]} == Recipients.cast(list)
13 end
14
15 test "it works with a list" do
16 list = ["https://lain.com/users/lain"]
17 assert {:ok, list} == Recipients.cast(list)
18 end
19
20 test "it works with a list with whole objects" do
21 list = ["https://lain.com/users/lain", %{"id" => "https://gensokyo.2hu/users/raymoo"}]
22 resulting_list = ["https://gensokyo.2hu/users/raymoo", "https://lain.com/users/lain"]
23 assert {:ok, resulting_list} == Recipients.cast(list)
24 end
25
26 test "it turns a single string into a list" do
27 recipient = "https://lain.com/users/lain"
28
29 assert {:ok, [recipient]} == Recipients.cast(recipient)
30 end
31 end