summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSavagePeanut <sourcehut@lazytapir.com>2024-01-20 18:59:41 -0600
committerSavagePeanut <sourcehut@lazytapir.com>2024-01-20 18:59:41 -0600
commit5e8d9ccf2f28936fabf6d155b37347d91a4fd1c5 (patch)
tree6c5333ecc6a6dcc83d61708c369ebb25ccc33ac5 /tests
parent91987c153449ea8b8ecb55cbc5968669e35454cb (diff)
style mentions. 1.6
Diffstat (limited to 'tests')
-rw-r--r--tests/test_matrix.py9
-rw-r--r--tests/test_telegram.py11
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_matrix.py b/tests/test_matrix.py
index edcfe37..29838bd 100644
--- a/tests/test_matrix.py
+++ b/tests/test_matrix.py
@@ -48,6 +48,15 @@ def test_basic():
formatted_body = "<span data-mx-spoiler>this message contains a spoiler</span>"
assert(format_for_matrix(test) == formatted_body)
+def test_basic_mention():
+ test = "SavagePeanut _underline_"
+ formatted_body = "<a href='https://matrix.to/#/@SavagePeanut:example.org'>SavagePeanut</a> <em>underline</em>"
+ assert(format_for_matrix(test, [("@SavagePeanut:example.org", 0, 12)]) == formatted_body)
+
+ test = "*bold* SavagePeanut"
+ formatted_body = "<strong>bold</strong> <a href='https://matrix.to/#/@SavagePeanut:example.org'>SavagePeanut</a>"
+ assert(format_for_matrix(test, [("@SavagePeanut:example.org", 7, 19)]) == formatted_body)
+
def test_empty():
test = "__ ** ~~ ``"
formatted_body = "__ ** ~~ ``"
diff --git a/tests/test_telegram.py b/tests/test_telegram.py
index 0b3dbdc..b9f3e44 100644
--- a/tests/test_telegram.py
+++ b/tests/test_telegram.py
@@ -48,6 +48,17 @@ def test_basic():
styles = [('spoiler', 11, 10, '')]
assert(format_for_telegram(test) == (formatted_body, styles))
+def test_basic_mention():
+ test = "SavagePeanut _underline_"
+ formatted_body = "SavagePeanut underline"
+ styles = [('mention', 0, 12, ''), ('italics', 13, 9, '')]
+ assert(format_for_telegram(test, [("SavagePeanut", 0, 12)]) == (formatted_body, styles))
+
+ test = "*bold* SavagePeanut"
+ formatted_body = "bold SavagePeanut"
+ styles = [('bold', 0, 4, ''), ('mention', 5, 12, '')]
+ assert(format_for_telegram(test, [("SavagePeanut", 7, 19)]) == (formatted_body, styles))
+
def test_quotes():
test = ">single"
formatted_body = ">single"