;;; ement-tests.el --- Tests for Ement.el -*- lexical-binding: t; -*- ;; Copyright (C) 2023 Free Software Foundation, Inc. ;; Author: Adam Porter ;; 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 . ;;; 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) "foo: hi")) (should (equal (ement--format-body-mentions "@foo:matrix.org: hi" room) "foo: hi")) (should (equal (ement--format-body-mentions "foo: hi" room) "foo: hi")) (should (equal (ement--format-body-mentions "@foo and @bar:matrix.org: hi" room) "foo and bar: hi")) (should (equal (ement--format-body-mentions "foo: how about you and @bar ..." room) "foo: how about you and bar ...")) (should (equal (ement--format-body-mentions "Hello, @foo:matrix.org." room) "Hello, foo.")) (should (equal (ement--format-body-mentions "Hello, @foo:matrix.org, how are you?" room) "Hello, foo, how are you?")))) (provide 'ement-tests) ;;; ement-tests.el ends here