Add unit tests for Utils.user_name_string
This commit is contained in:
parent
1377ec33fe
commit
c38f1aefb1
2 changed files with 28 additions and 2 deletions
|
@ -77,4 +77,32 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
|
|||
assert Utils.scrub_html_and_truncate("Pleroma's really cool!") == "Pleroma's really cool!"
|
||||
end
|
||||
end
|
||||
|
||||
describe "user_name_string/1" do
|
||||
test "it uses the Endpoint by default" do
|
||||
Pleroma.Web.Endpoint.config_change(
|
||||
[{Pleroma.Web.Endpoint, url: [host: "sub.example.com"]}],
|
||||
[]
|
||||
)
|
||||
|
||||
user = insert(:user)
|
||||
|
||||
assert Utils.user_name_string(user) == "#{user.name} (@#{user.nickname}@sub.example.com)"
|
||||
end
|
||||
|
||||
test "it uses any custom WebFinger domain" do
|
||||
Pleroma.Web.Endpoint.config_change(
|
||||
[{Pleroma.Web.Endpoint, url: [host: "sub.example.com"]}],
|
||||
[]
|
||||
)
|
||||
|
||||
clear_config([Pleroma.Web.Endpoint, :url, :host], "sub.example.com")
|
||||
|
||||
clear_config([Pleroma.Web.WebFinger, :domain], "example.com")
|
||||
|
||||
user = insert(:user)
|
||||
|
||||
assert Utils.user_name_string(user) == "#{user.name} (@#{user.nickname}@example.com)"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -61,8 +61,6 @@ defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
|
|||
|
||||
user = insert(:user, ap_id: "https://sub.example.com/users/bobby", nickname: "bobby")
|
||||
|
||||
assert Utils.user_name_string(user) == "#{user.name} (@bobby@example.com)"
|
||||
|
||||
response =
|
||||
build_conn()
|
||||
|> put_req_header("accept", "application/jrd+json")
|
||||
|
|
Loading…
Reference in a new issue