76e3bd6e62179f46aace0d0ea16fa094076ce876
[akkoma] / test / web / twitter_api / representers / user_representer_test.exs
1 defmodule Pleroma.Web.TwitterAPI.Representers.UserRepresenterTest do
2 use Pleroma.DataCase
3
4 alias Pleroma.User
5 alias Pleroma.Web.TwitterAPI.Representers.UserRepresenter
6 alias Pleroma.Builders.UserBuilder
7
8 setup do
9 {:ok, user} = UserBuilder.insert
10 [user: user]
11 end
12
13 test "A user", %{user: user} do
14 image = "https://placehold.it/48x48"
15 represented = %{
16 "id" => user.id,
17 "name" => user.name,
18 "screen_name" => user.nickname,
19 "description" => user.bio,
20 # Fake fields
21 "favourites_count" => 0,
22 "statuses_count" => 0,
23 "friends_count" => 0,
24 "followers_count" => 0,
25 "profile_image_url" => image,
26 "profile_image_url_https" => image,
27 "profile_image_url_profile_size" => image,
28 "profile_image_url_original" => image,
29 "following" => false,
30 "rights" => %{}
31 }
32
33 assert represented == UserRepresenter.to_map(user)
34 end
35
36 test "A user for a given other follower", %{user: user} do
37 {:ok, follower} = UserBuilder.insert(%{following: [User.ap_followers(user)]})
38 image = "https://placehold.it/48x48"
39 represented = %{
40 "id" => user.id,
41 "name" => user.name,
42 "screen_name" => user.nickname,
43 "description" => user.bio,
44 # Fake fields
45 "favourites_count" => 0,
46 "statuses_count" => 0,
47 "friends_count" => 0,
48 "followers_count" => 0,
49 "profile_image_url" => image,
50 "profile_image_url_https" => image,
51 "profile_image_url_profile_size" => image,
52 "profile_image_url_original" => image,
53 "following" => true,
54 "rights" => %{}
55 }
56
57 assert represented == UserRepresenter.to_map(user, %{for: follower})
58 end
59 end