move to 2.5.5
[anni] / test / pleroma / following_relationship_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.FollowingRelationshipTest do
6   use Pleroma.DataCase, async: true
7
8   alias Pleroma.FollowingRelationship
9   alias Pleroma.Web.ActivityPub.InternalFetchActor
10   alias Pleroma.Web.ActivityPub.Relay
11
12   import Pleroma.Factory
13
14   describe "following/1" do
15     test "returns following addresses without internal.fetch" do
16       user = insert(:user)
17       fetch_actor = InternalFetchActor.get_actor()
18       FollowingRelationship.follow(fetch_actor, user, :follow_accept)
19       assert FollowingRelationship.following(fetch_actor) == [user.follower_address]
20     end
21
22     test "returns following addresses without relay" do
23       user = insert(:user)
24       relay_actor = Relay.get_actor()
25       FollowingRelationship.follow(relay_actor, user, :follow_accept)
26       assert FollowingRelationship.following(relay_actor) == [user.follower_address]
27     end
28
29     test "returns following addresses without remote user" do
30       user = insert(:user)
31       actor = insert(:user, local: false)
32       FollowingRelationship.follow(actor, user, :follow_accept)
33       assert FollowingRelationship.following(actor) == [user.follower_address]
34     end
35
36     test "returns following addresses with local user" do
37       user = insert(:user)
38       actor = insert(:user, local: true)
39       FollowingRelationship.follow(actor, user, :follow_accept)
40
41       assert FollowingRelationship.following(actor) == [
42                actor.follower_address,
43                user.follower_address
44              ]
45     end
46   end
47 end