MastoAPI: Fix date in account view.
[akkoma] / test / web / mastodon_api / account_view_test.exs
1 defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
2 use Pleroma.DataCase
3 import Pleroma.Factory
4 alias Pleroma.Web.MastodonAPI.AccountView
5 alias Pleroma.User
6
7 test "Represent a user account" do
8 user = insert(:user, %{info: %{"note_count" => 5, "follower_count" => 3}, nickname: "shp@shitposter.club", inserted_at: ~N[2017-08-15 15:47:06.597036]})
9
10 expected = %{
11 id: user.id,
12 username: "shp",
13 acct: user.nickname,
14 display_name: user.name,
15 locked: false,
16 created_at: "2017-08-15T15:47:06.000Z",
17 followers_count: 3,
18 following_count: 0,
19 statuses_count: 5,
20 note: user.bio,
21 url: user.ap_id,
22 avatar: "https://placehold.it/48x48",
23 avatar_static: "https://placehold.it/48x48",
24 header: "https://placehold.it/700x335",
25 header_static: "https://placehold.it/700x335"
26 }
27
28 assert expected == AccountView.render("account.json", %{user: user})
29 end
30
31 test "Represent a smaller mention" do
32 user = insert(:user)
33
34 expected = %{
35 id: user.id,
36 acct: user.nickname,
37 username: user.nickname,
38 url: user.ap_id
39 }
40
41 assert expected == AccountView.render("mention.json", %{user: user})
42 end
43
44 test "represent a relationship" do
45 user = insert(:user)
46 other_user = insert(:user)
47
48 {:ok, user} = User.follow(user, other_user)
49
50 expected = %{
51 id: other_user.id,
52 following: true,
53 followed_by: false,
54 blocking: false,
55 muting: false,
56 requested: false,
57 domain_blocking: false
58 }
59
60 assert expected == AccountView.render("relationship.json", %{user: user, target: other_user})
61 end
62 end