1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
8 alias Pleroma.Web.MastodonAPI.AccountView
11 test "Represent a user account" do
16 "icon" => %{"url" => "/file.png"},
17 "name" => ":karjalanpiirakka:"
24 info: %{note_count: 5, follower_count: 3, source_data: source_data},
25 nickname: "shp@shitposter.club",
26 name: ":karjalanpiirakka: shp",
27 bio: "<script src=\"invalid-html\"></script><span>valid html</span>",
28 inserted_at: ~N[2017-08-15 15:47:06.597036]
32 id: to_string(user.id),
35 display_name: user.name,
37 created_at: "2017-08-15T15:47:06.000Z",
41 note: "<span>valid html</span>",
43 avatar: "http://localhost:4001/images/avi.png",
44 avatar_static: "http://localhost:4001/images/avi.png",
45 header: "http://localhost:4001/images/banner.png",
46 header_static: "http://localhost:4001/images/banner.png",
49 "static_url" => "/file.png",
51 "shortcode" => "karjalanpiirakka",
52 "visible_in_picker" => false
63 confirmation_pending: false,
70 assert expected == AccountView.render("account.json", %{user: user})
73 test "Represent a Service(bot) account" do
76 info: %{note_count: 5, follower_count: 3, source_data: %{"type" => "Service"}},
77 nickname: "shp@shitposter.club",
78 inserted_at: ~N[2017-08-15 15:47:06.597036]
82 id: to_string(user.id),
85 display_name: user.name,
87 created_at: "2017-08-15T15:47:06.000Z",
93 avatar: "http://localhost:4001/images/avi.png",
94 avatar_static: "http://localhost:4001/images/avi.png",
95 header: "http://localhost:4001/images/banner.png",
96 header_static: "http://localhost:4001/images/banner.png",
106 confirmation_pending: false,
113 assert expected == AccountView.render("account.json", %{user: user})
116 test "Represent a smaller mention" do
120 id: to_string(user.id),
122 username: user.nickname,
126 assert expected == AccountView.render("mention.json", %{user: user})
129 test "represent a relationship" do
131 other_user = insert(:user)
133 {:ok, user} = User.follow(user, other_user)
134 {:ok, user} = User.block(user, other_user)
137 id: to_string(other_user.id),
142 muting_notifications: false,
144 domain_blocking: false,
145 showing_reblogs: false,
149 assert expected == AccountView.render("relationship.json", %{user: user, target: other_user})