emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ement 7ac1ff9c0a 1/2: Tests: Add test for ement--format


From: ELPA Syncer
Subject: [elpa] externals/ement 7ac1ff9c0a 1/2: Tests: Add test for ement--format-body-mentions
Date: Sun, 16 Apr 2023 00:57:37 -0400 (EDT)

branch: externals/ement
commit 7ac1ff9c0af1b04c97bb3d557f53089e827bd7f6
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Tests: Add test for ement--format-body-mentions
---
 tests/ement-tests.el | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/tests/ement-tests.el b/tests/ement-tests.el
new file mode 100644
index 0000000000..b10e8a4bc5
--- /dev/null
+++ b/tests/ement-tests.el
@@ -0,0 +1,58 @@
+;;; ement-tests.el --- Tests for Ement.el                  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2023  Free Software Foundation, Inc.
+
+;; Author: Adam Porter <adam@alphapapa.net>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; 
+
+;;; Code:
+
+(require 'ert)
+(require 'map)
+
+(require 'ement-lib)
+
+;;;; Tests
+
+(ert-deftest ement--format-body-mentions ()
+  (let ((room (make-ement-room
+               :members (map-into
+                         `(("@foo:matrix.org" . ,(make-ement-user :id 
"@foo:matrix.org"
+                                                                  :displayname 
"foo"))
+                           ("@bar:matrix.org" . ,(make-ement-user :id 
"@bar:matrix.org"
+                                                                  :displayname 
"bar")))
+                         '(hash-table :test equal)))))
+    (should (equal (ement--format-body-mentions "@foo: hi" room)
+                   "<a href=\"https://matrix.to/#/@foo:matrix.org\";>foo</a>: 
hi"))
+    (should (equal (ement--format-body-mentions "@foo:matrix.org: hi" room)
+                   "<a href=\"https://matrix.to/#/@foo:matrix.org\";>foo</a>: 
hi"))
+    (should (equal (ement--format-body-mentions "foo: hi" room)
+                   "<a href=\"https://matrix.to/#/@foo:matrix.org\";>foo</a>: 
hi"))
+    (should (equal (ement--format-body-mentions "@foo and @bar:matrix.org: hi" 
room)
+                   "<a href=\"https://matrix.to/#/@foo:matrix.org\";>foo</a> 
and <a href=\"https://matrix.to/#/@bar:matrix.org\";>bar</a>: hi"))
+    (should (equal (ement--format-body-mentions "foo: how about you and @bar 
..." room)
+                   "<a href=\"https://matrix.to/#/@foo:matrix.org\";>foo</a>: 
how about you and <a href=\"https://matrix.to/#/@bar:matrix.org\";>bar</a> ..."))
+    (should (equal (ement--format-body-mentions "Hello, @foo:matrix.org." room)
+                   "Hello, <a 
href=\"https://matrix.to/#/@foo:matrix.org\";>foo</a>."))
+    (should (equal (ement--format-body-mentions "Hello, @foo:matrix.org, how 
are you?" room)
+                   "Hello, <a 
href=\"https://matrix.to/#/@foo:matrix.org\";>foo</a>, how are you?"))))
+
+(provide 'ement-tests)
+
+;;; ement-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]