1 defmodule Pleroma.FormatterTest do
2 alias Pleroma.Formatter
8 test "turning urls into links" do
9 text = "Hey, check out https://www.youtube.com/watch?v=8Zg1-TufF%20zY?x=1&y=2#blabla."
11 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>."
13 assert Formatter.linkify(text) == expected
17 describe ".parse_tags" do
18 test "parses tags in the text" do
19 text = "Here's a #test. Maybe these are #working or not. What about #漢字? And #は。"
22 {"#working", "working"},
27 assert Formatter.parse_tags(text) == expected
31 test "it can parse mentions and return the relevant users" do
32 text = "@gsimg According to @archaeme, that is @daggsy. Also hello @archaeme@archae.me"
34 gsimg = insert(:user, %{nickname: "gsimg"})
35 archaeme = insert(:user, %{nickname: "archaeme"})
36 archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"})
40 {"@archaeme", archaeme},
41 {"@archaeme@archae.me", archaeme_remote},
44 assert Formatter.parse_mentions(text) == expected_result