Move mention parsing to Formatter module.
This commit is contained in:
parent
9376443973
commit
1af9c77736
4 changed files with 32 additions and 29 deletions
|
|
@ -240,22 +240,6 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
assert is_binary(response)
|
||||
end
|
||||
|
||||
test "it can parse mentions and return the relevant users" do
|
||||
text = "@gsimg According to @archaeme, that is @daggsy. Also hello @archaeme@archae.me"
|
||||
|
||||
gsimg = insert(:user, %{nickname: "gsimg"})
|
||||
archaeme = insert(:user, %{nickname: "archaeme"})
|
||||
archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"})
|
||||
|
||||
expected_result = [
|
||||
{"@gsimg", gsimg},
|
||||
{"@archaeme", archaeme},
|
||||
{"@archaeme@archae.me", archaeme_remote},
|
||||
]
|
||||
|
||||
assert TwitterAPI.parse_mentions(text) == expected_result
|
||||
end
|
||||
|
||||
test "it adds user links to an existing text" do
|
||||
text = "@gsimg According to @archaeme, that is @daggsy. Also hello @archaeme@archae.me"
|
||||
|
||||
|
|
@ -263,7 +247,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
archaeme = insert(:user, %{nickname: "archaeme"})
|
||||
archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"})
|
||||
|
||||
mentions = TwitterAPI.parse_mentions(text)
|
||||
mentions = Pleroma.Formatter.parse_mentions(text)
|
||||
expected_text = "<a href='#{gsimg.ap_id}'>@gsimg</a> According to <a href='#{archaeme.ap_id}'>@archaeme</a>, that is @daggsy. Also hello <a href='#{archaeme_remote.ap_id}'>@archaeme</a>"
|
||||
|
||||
assert Utils.add_user_links(text, mentions) == expected_text
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue