2020-05-12 09:08:00 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
2022-02-25 23:11:42 -07:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2020-05-12 09:08:00 -06:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.Preload.Providers.UserTest do
|
2020-12-21 04:21:40 -07:00
|
|
|
use Pleroma.DataCase, async: true
|
2020-05-12 09:08:00 -06:00
|
|
|
import Pleroma.Factory
|
|
|
|
alias Pleroma.Web.Preload.Providers.User
|
|
|
|
|
|
|
|
describe "returns empty when user doesn't exist" do
|
|
|
|
test "nil user specified" do
|
2020-06-29 03:06:20 -06:00
|
|
|
assert User.generate_terms(%{user: nil}) == %{}
|
2020-05-12 09:08:00 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
test "missing user specified" do
|
2020-06-29 03:06:20 -06:00
|
|
|
assert User.generate_terms(%{user: :not_a_user}) == %{}
|
2020-05-12 09:08:00 -06:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "specified user exists" do
|
|
|
|
setup do
|
|
|
|
user = insert(:user)
|
|
|
|
|
2020-06-29 03:06:20 -06:00
|
|
|
terms = User.generate_terms(%{user: user})
|
|
|
|
%{terms: terms, user: user}
|
2020-05-12 09:08:00 -06:00
|
|
|
end
|
|
|
|
|
2020-06-29 03:06:20 -06:00
|
|
|
test "account is rendered", %{terms: terms, user: user} do
|
2020-06-29 03:41:00 -06:00
|
|
|
account = terms["/api/v1/accounts/#{user.id}"]
|
2020-06-29 03:06:20 -06:00
|
|
|
assert %{acct: user, username: user} = account
|
2020-05-12 09:08:00 -06:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|