Add unit tests for Utils.user_name_string

This commit is contained in:
Walter Huf 2023-07-28 07:35:00 -07:00
parent 1377ec33fe
commit c38f1aefb1
2 changed files with 28 additions and 2 deletions

View file

@ -77,4 +77,32 @@ test "it returns text without encode HTML" do
assert Utils.scrub_html_and_truncate("Pleroma's really cool!") == "Pleroma's really cool!" assert Utils.scrub_html_and_truncate("Pleroma's really cool!") == "Pleroma's really cool!"
end end
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 end

View file

@ -61,8 +61,6 @@ test "reach user on tld, while pleroma is runned on subdomain" do
user = insert(:user, ap_id: "https://sub.example.com/users/bobby", nickname: "bobby") 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 = response =
build_conn() build_conn()
|> put_req_header("accept", "application/jrd+json") |> put_req_header("accept", "application/jrd+json")