Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into finch
[akkoma] / test / pleroma / web / mastodon_api / views / suggestion_view_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.Web.MastodonAPI.SuggestionViewTest do
6 use Pleroma.DataCase, async: true
7 import Pleroma.Factory
8 alias Pleroma.Web.MastodonAPI.SuggestionView, as: View
9
10 test "show.json" do
11 user = insert(:user, is_suggested: true)
12 json = View.render("show.json", %{user: user, source: :staff, skip_visibility_check: true})
13
14 assert json.source == :staff
15 assert json.account.id == user.id
16 end
17
18 test "index.json" do
19 user1 = insert(:user, is_suggested: true)
20 user2 = insert(:user, is_suggested: true)
21 user3 = insert(:user, is_suggested: true)
22
23 [suggestion1, suggestion2, suggestion3] =
24 View.render("index.json", %{
25 users: [user1, user2, user3],
26 source: :staff,
27 skip_visibility_check: true
28 })
29
30 assert suggestion1.source == :staff
31 assert suggestion2.account.id == user2.id
32 assert suggestion3.account.url == user3.ap_id
33 end
34 end