Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

55 rindas
1.7KB

  1. defmodule Pleroma.FormatterTest do
  2. alias Pleroma.Formatter
  3. use Pleroma.DataCase
  4. import Pleroma.Factory
  5. describe ".linkify" do
  6. test "turning urls into links" do
  7. text = "Hey, check out https://www.youtube.com/watch?v=8Zg1-TufF%20zY?x=1&y=2#blabla."
  8. expected = "Hey, check out <a href='https://www.youtube.com/watch?v=8Zg1-TufF%20zY?x=1&y=2#blabla'>https://www.youtube.com/watch?v=8Zg1-TufF%20zY?x=1&y=2#blabla</a>."
  9. assert Formatter.linkify(text) == expected
  10. end
  11. end
  12. describe ".parse_tags" do
  13. test "parses tags in the text" do
  14. text = "Here's a #Test. Maybe these are #working or not. What about #漢字? And #は。"
  15. expected = [
  16. {"#Test", "test"},
  17. {"#working", "working"},
  18. {"#漢字", "漢字"},
  19. {"#は", "は"}
  20. ]
  21. assert Formatter.parse_tags(text) == expected
  22. end
  23. end
  24. test "it can parse mentions and return the relevant users" do
  25. text = "@gsimg According to @archaeme, that is @daggsy. Also hello @archaeme@archae.me"
  26. gsimg = insert(:user, %{nickname: "gsimg"})
  27. archaeme = insert(:user, %{nickname: "archaeme"})
  28. archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"})
  29. expected_result = [
  30. {"@gsimg", gsimg},
  31. {"@archaeme", archaeme},
  32. {"@archaeme@archae.me", archaeme_remote},
  33. ]
  34. assert Formatter.parse_mentions(text) == expected_result
  35. end
  36. test "it adds cool emoji" do
  37. text = "I love :moominmamma:"
  38. expected_result = "I love <img height='32px' width='32px' alt='moominmamma' title='moominmamma' src='#{Pleroma.Web.Endpoint.static_url}/finmoji/128px/moominmamma-128.png' />"
  39. assert Formatter.finmojifiy(text) == expected_result
  40. end
  41. end